2017-05-08 52 views
1

我想武官失火指令使用XML定義的調度插件Quartz調度例外,同時增加失火指令到調度

(作業應該每分鐘運行一次,如果工作擦槍走火它應該什麼也不做,計劃運行的下一個作業)

<schedule> 
    <job> 
     <name>MyJob</name> 
     <group>MyGroup</group> 
     <description>My job description</description> 
     <job-class>com.path.to.MyJobClass</job-class>  
    </job> 

    <trigger> 
     <cron> 
      <name>JobCronTrigger</name> 
      <description> 
       bla bla 
      </description> 
      <job-name>MyJob</job-name> 
      <job-group>MyGroup</job-group> 
      <cron-expression>0 0/1 * 1/1 * ?</cron-expression> 
      <misfire-instruction>MISFIRE_INSTRUCTION_DO_NOTHING</misfire-instruction> 
     </cron> 
    </trigger> 
</schedule> 

我發現了一個XML驗證異常與此消息

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: 
Invalid content was found starting with element 'time-zone'. One of 
'{"http://www.quartz-scheduler.org/xml/JobSchedulingData":priority, 
"http://www.quartz-scheduler.org/xml/JobSchedulingData":calendar-name, 
"http://www.quartz-scheduler.org/xml/JobSchedulingData":job-data-map, 
"http://www.quartz-scheduler.org/xml/JobSchedulingData":start-time, 
"http://www.quartz-scheduler.org/xml/JobSchedulingData":start-time-seconds-in-future, 
"http://www.quartz-scheduler.org/xml/JobSchedulingData":misfire-instruction, 
"http://www.quartz-scheduler.org/xml/JobSchedulingData":cron-expression}' 
is expected. 

我已經嘗試添加<time-zone>UTC</time-zone到cron定義,但我只是有更多的驗證錯誤。 不用說,當我刪除

MISFIRE_INSTRUCTION_DO_NOTHING

,一切運行良好。那麼我該如何修復我的XML?

我使用Quartz 2.3.0

回答

3

按照Quartz XSDmisfire-instruction元素必須先於​​之一。

這就是錯誤信息告訴你的。它提到了time-zone元素,因爲這是在​​之後唯一有效元素

+0

是的,你是對的,謝謝! – svarog