{"id":8788,"date":"2024-05-27T09:02:03","date_gmt":"2024-05-27T01:02:03","guid":{"rendered":""},"modified":"2024-05-27T09:02:03","modified_gmt":"2024-05-27T01:02:03","slug":"quartz\u539f\u7406\u5206\u6790_\u5355\u7247\u673a\u5b9a\u65f6\u5668\u539f\u7406[\u901a\u4fd7\u6613\u61c2]","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8788.html","title":{"rendered":"quartz\u539f\u7406\u5206\u6790_\u5355\u7247\u673a\u5b9a\u65f6\u5668\u539f\u7406[\u901a\u4fd7\u6613\u61c2]"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n
\n

\n
\n \n <\/path> \n <\/svg> <\/p>\n

    \u4e00\u3001Quartz \u57fa\u672c\u4ecb\u7ecd<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<\/article>\n

           1.1 Quartz \u6982\u8ff0<\/p>\n

           1.2 Quartz\u7279\u70b9<\/p>\n

           1.3 Quartz \u96c6\u7fa4\u914d\u7f6e<\/p>\n

    \u4e8c\u3001Quartz \u539f\u7406\u53ca\u6d41\u7a0b<\/p>\n

           2.1 quartz\u57fa\u672c\u539f\u7406<\/p>\n

           2.2 quartz\u542f\u52a8\u6d41\u7a0b<\/p>\n

   \u4e09\u3001Spring + Quartz \u5b9e\u73b0\u4f01\u4e1a\u7ea7\u8c03\u5ea6\u7684\u5b9e\u73b0\u793a\u4f8b<\/p>\n

          3.1 \u73af\u5883\u4fe1\u606f<\/p>\n

          3.2 \u76f8\u5173\u4ee3\u7801\u53ca\u914d\u7f6e<\/p>\n

    \u56db\u3001\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848<\/p>\n

    \u4e94\u3001\u76f8\u5173\u77e5\u8bc6<\/p>\n

    \u516d\u3001\u53c2\u8003\u8d44\u6599<\/p>\n

     \u603b\u7ed3<\/p>\n

      <\/p>\n

<\/span><\/p>\n

\u4e00\u3001Quartz \u57fa\u672c\u4ecb\u7ecd<\/h2>\n

<\/span><\/p>\n

    <\/strong>1.1 Quartz \u6982\u8ff0<\/h3>\n

           Quartz \u662f OpenSymphony \u5f00\u6e90\u7ec4\u7ec7\u5728\u4efb\u52a1\u8c03\u5ea6\u9886\u57df\u7684\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u5b8c\u5168\u57fa\u4e8e Java \u5b9e\u73b0\u3002\u8be5\u9879\u76ee\u4e8e 2009 \u5e74\u88ab Terracotta \u6536\u8d2d\uff0c\u76ee\u524d\u662f Terracotta \u65d7\u4e0b\u7684\u4e00\u4e2a\u9879\u76ee\u3002\u8bfb\u8005\u53ef\u4ee5\u5230 http:\/\/www.quartz-scheduler.org\/\u7ad9\u70b9\u4e0b\u8f7d Quartz \u7684\u53d1\u5e03\u7248\u672c\u53ca\u5176\u6e90\u4ee3\u7801\u3002<\/p>\n

<\/span><\/p>\n

   1.2 Quartz\u7279\u70b9<\/h3>\n

       \u4f5c\u4e3a\u4e00\u4e2a\u4f18\u79c0\u7684\u5f00\u6e90\u8c03\u5ea6\u6846\u67b6\uff0cQuartz \u5177\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a<\/p>\n

    \n
  1. \u5f3a\u5927\u7684\u8c03\u5ea6\u529f\u80fd\uff0c\u4f8b\u5982\u652f\u6301\u4e30\u5bcc\u591a\u6837\u7684\u8c03\u5ea6\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6ee1\u8db3\u5404\u79cd\u5e38\u89c4\u53ca\u7279\u6b8a\u9700\u6c42\uff1b<\/li>\n
  2. \u7075\u6d3b\u7684\u5e94\u7528\u65b9\u5f0f\uff0c\u4f8b\u5982\u652f\u6301\u4efb\u52a1\u548c\u8c03\u5ea6\u7684\u591a\u79cd\u7ec4\u5408\u65b9\u5f0f\uff0c\u652f\u6301\u8c03\u5ea6\u6570\u636e\u7684\u591a\u79cd\u5b58\u50a8\u65b9\u5f0f\uff1b<\/li>\n
  3. \u5206\u5e03\u5f0f\u548c\u96c6\u7fa4\u80fd\u529b\uff0cTerracotta \u6536\u8d2d\u540e\u5728\u539f\u6765\u529f\u80fd\u57fa\u7840\u4e0a\u4f5c\u4e86\u8fdb\u4e00\u6b65\u63d0\u5347\u3002<\/li>\n<\/ol>\n

          \u53e6\u5916\uff0c\u4f5c\u4e3a Spring \u9ed8\u8ba4\u7684\u8c03\u5ea6\u6846\u67b6\uff0cQuartz \u5f88\u5bb9\u6613\u4e0e Spring \u96c6\u6210\u5b9e\u73b0\u7075\u6d3b\u53ef\u914d\u7f6e\u7684\u8c03\u5ea6\u529f\u80fd\u3002<\/p>\n

        quartz\u8c03\u5ea6\u6838\u5fc3\u5143\u7d20<\/strong>\uff1a<\/p>\n

      \n
    1. Scheduler:\u4efb\u52a1\u8c03\u5ea6\u5668\uff0c\u662f\u5b9e\u9645\u6267\u884c\u4efb\u52a1\u8c03\u5ea6\u7684\u63a7\u5236\u5668\u3002\u5728spring\u4e2d\u901a\u8fc7SchedulerFactoryBean\u5c01\u88c5\u8d77\u6765\u3002<\/li>\n
    2. Trigger\uff1a\u89e6\u53d1\u5668\uff0c\u7528\u4e8e\u5b9a\u4e49\u4efb\u52a1\u8c03\u5ea6\u7684\u65f6\u95f4\u89c4\u5219\uff0c\u6709SimpleTrigger,CronTrigger,DateIntervalTrigger\u548cNthIncludedDayTrigger\uff0c\u5176\u4e2dCronTrigger\u7528\u7684\u6bd4\u8f83\u591a\uff0c\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u8fd9\u79cd\u65b9\u5f0f\u3002CronTrigger\u5728spring\u4e2d\u5c01\u88c5\u5728CronTriggerFactoryBean\u4e2d\u3002<\/li>\n
    3. Calendar:\u5b83\u662f\u4e00\u4e9b\u65e5\u5386\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u96c6\u5408\u3002\u4e00\u4e2atrigger\u53ef\u4ee5\u5305\u542b\u591a\u4e2aCalendar\uff0c\u4ee5\u4fbf\u6392\u9664\u6216\u5305\u542b\u67d0\u4e9b\u65f6\u95f4\u70b9\u3002<\/li>\n
    4. JobDetail:\u7528\u6765\u63cf\u8ff0Job\u5b9e\u73b0\u7c7b\u53ca\u5176\u5b83\u76f8\u5173\u7684\u9759\u6001\u4fe1\u606f\uff0c\u5982Job\u540d\u5b57\u3001\u5173\u8054\u76d1\u542c\u5668\u7b49\u4fe1\u606f\u3002\u5728spring\u4e2d\u6709JobDetailFactoryBean\u548c MethodInvokingJobDetailFactoryBean\u4e24\u79cd\u5b9e\u73b0\uff0c\u5982\u679c\u4efb\u52a1\u8c03\u5ea6\u53ea\u9700\u8981\u6267\u884c\u67d0\u4e2a\u7c7b\u7684\u67d0\u4e2a\u65b9\u6cd5\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7MethodInvokingJobDetailFactoryBean\u6765\u8c03\u7528\u3002<\/li>\n
    5. Job\uff1a\u662f\u4e00\u4e2a\u63a5\u53e3\uff0c\u53ea\u6709\u4e00\u4e2a\u65b9\u6cd5void execute(JobExecutionContext context),\u5f00\u53d1\u8005\u5b9e\u73b0\u8be5\u63a5\u53e3\u5b9a\u4e49\u8fd0\u884c\u4efb\u52a1\uff0cJobExecutionContext\u7c7b\u63d0\u4f9b\u4e86\u8c03\u5ea6\u4e0a\u4e0b\u6587\u7684\u5404\u79cd\u4fe1\u606f\u3002Job\u8fd0\u884c\u65f6\u7684\u4fe1\u606f\u4fdd\u5b58\u5728JobDataMap\u5b9e\u4f8b\u4e2d\u3002\u5b9e\u73b0Job\u63a5\u53e3\u7684\u4efb\u52a1\uff0c\u9ed8\u8ba4\u662f\u65e0\u72b6\u6001\u7684\uff0c\u82e5\u8981\u5c06Job\u8bbe\u7f6e\u6210\u6709\u72b6\u6001\u7684\uff0c\u5728quartz\u4e2d\u662f\u7ed9\u5b9e\u73b0\u7684Job\u6dfb\u52a0@DisallowConcurrentExecution\u6ce8\u89e3\uff08\u4ee5\u524d\u662f\u5b9e\u73b0StatefulJob\u63a5\u53e3\uff0c\u73b0\u5728\u5df2\u88abDeprecated\uff09,\u5728\u4e0espring\u7ed3\u5408\u4e2d\u53ef\u4ee5\u5728spring\u914d\u7f6e\u6587\u4ef6\u7684job detail\u4e2d\u914d\u7f6econcurrent\u53c2\u6570\u3002<\/li>\n<\/ol>\n

      <\/span><\/p>\n

        1.3 Quartz \u96c6\u7fa4\u914d\u7f6e<\/h3>\n

           <\/p>\n

      quartz\u96c6\u7fa4\u662f\u901a\u8fc7\u6570\u636e\u5e93\u8868\u6765\u611f\u77e5\u5176\u4ed6\u7684\u5e94\u7528\u7684\uff0c\u5404\u4e2a\u8282\u70b9\u4e4b\u95f4\u5e76\u6ca1\u6709\u76f4\u63a5\u7684\u901a\u4fe1\u3002\u53ea\u6709\u4f7f\u7528\u6301\u4e45\u7684JobStore\u624d\u80fd\u5b8c\u6210Quartz\u96c6\u7fa4\u3002
      \u6570\u636e\u5e93\u8868\uff1a\u4ee5\u524d\u670912\u5f20\u8868\uff0c\u73b0\u5728\u53ea\u670911\u5f20\u8868\uff0c\u73b0\u5728\u6ca1\u6709\u5b58\u50a8listener\u76f8\u5173\u7684\u8868\uff0c\u591a\u4e86QRTZ_SIMPROP_TRIGGERS\u8868\uff1a<\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
      Table name<\/th>\nDescription<\/th>\n<\/tr>\n<\/tbody>\n
      QRTZ_CALENDARS<\/td>\n\u5b58\u50a8Quartz\u7684Calendar\u4fe1\u606f<\/td>\n<\/tr>\n
      QRTZ_CRON_TRIGGERS<\/td>\n\u5b58\u50a8CronTrigger\uff0c\u5305\u62ecCron\u8868\u8fbe\u5f0f\u548c\u65f6\u533a\u4fe1\u606f<\/td>\n<\/tr>\n
      QRTZ_FIRED_TRIGGERS<\/td>\n\u5b58\u50a8\u4e0e\u5df2\u89e6\u53d1\u7684Trigger\u76f8\u5173\u7684\u72b6\u6001\u4fe1\u606f\uff0c\u4ee5\u53ca\u76f8\u8054Job\u7684\u6267\u884c\u4fe1\u606f<\/td>\n<\/tr>\n
      QRTZ_PAUSED_TRIGGER_GRPS<\/td>\n\u5b58\u50a8\u5df2\u6682\u505c\u7684Trigger\u7ec4\u7684\u4fe1\u606f<\/td>\n<\/tr>\n
      QRTZ_SCHEDULER_STATE<\/td>\n\u5b58\u50a8\u5c11\u91cf\u7684\u6709\u5173Scheduler\u7684\u72b6\u6001\u4fe1\u606f\uff0c\u548c\u522b\u7684Scheduler\u5b9e\u4f8b<\/td>\n<\/tr>\n
      QRTZ_LOCKS<\/strong><\/td>\n\u5b58\u50a8\u7a0b\u5e8f\u7684\u60b2\u89c2\u9501\u7684\u4fe1\u606f<\/td>\n<\/tr>\n
      QRTZ_JOB_DETAILS<\/td>\n\u5b58\u50a8\u6bcf\u4e00\u4e2a\u5df2\u914d\u7f6e\u7684Job\u7684\u8be6\u7ec6\u4fe1\u606f<\/td>\n<\/tr>\n
      QRTZ_SIMPLE_TRIGGERS<\/td>\n\u5b58\u50a8\u7b80\u5355\u7684Trigger\uff0c\u5305\u62ec\u91cd\u590d\u6b21\u6570\u3001\u95f4\u9694\u3001\u4ee5\u53ca\u5df2\u89e6\u7684\u6b21\u6570<\/td>\n<\/tr>\n
      QRTZ_BLOG_TRIGGERS<\/td>\nTrigger\u4f5c\u4e3aBlob\u7c7b\u578b\u5b58\u50a8<\/td>\n<\/tr>\n
      QRTZ_TRIGGERS<\/td>\n\u5b58\u50a8\u5df2\u914d\u7f6e\u7684Trigger\u7684\u4fe1\u606f<\/td>\n<\/tr>\n
      QRTZ_SIMPROP_TRIGGERS<\/td>\n <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

      QRTZ_LOCKS\u5c31\u662fQuartz\u96c6\u7fa4\u5b9e\u73b0\u540c\u6b65\u673a\u5236\u7684\u884c\u9501\u8868,\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u9501\uff1aCALENDAR_ACCESS \u3001JOB_ACCESS\u3001MISFIRE_ACCESS \u3001STATE_ACCESS \u3001TRIGGER_ACCESS\u3002<\/p>\n

      <\/span><\/p>\n

        \u4e8c\u3001Quartz \u539f\u7406\u53ca\u6d41\u7a0b<\/h2>\n

      <\/span><\/p>\n

            2.1 quartz\u57fa\u672c\u539f\u7406<\/h3>\n

               <\/p>\n

      \u6838\u5fc3\u5143\u7d20<\/strong><\/p>\n

      Quartz \u4efb\u52a1\u8c03\u5ea6\u7684\u6838\u5fc3\u5143\u7d20\u662f scheduler, trigger \u548c job\uff0c\u5176\u4e2d trigger \u548c job \u662f\u4efb\u52a1\u8c03\u5ea6\u7684\u5143\u6570\u636e\uff0c scheduler \u662f\u5b9e\u9645\u6267\u884c\u8c03\u5ea6\u7684\u63a7\u5236\u5668\u3002<\/p>\n

      \u5728 Quartz \u4e2d\uff0ctrigger \u662f\u7528\u4e8e\u5b9a\u4e49\u8c03\u5ea6\u65f6\u95f4\u7684\u5143\u7d20\uff0c\u5373\u6309\u7167\u4ec0\u4e48\u65f6\u95f4\u89c4\u5219\u53bb\u6267\u884c\u4efb\u52a1\u3002Quartz \u4e2d\u4e3b\u8981\u63d0\u4f9b\u4e86\u56db\u79cd\u7c7b\u578b\u7684 trigger\uff1aSimpleTrigger\uff0cCronTirgger\uff0cDateIntervalTrigger\uff0c\u548c NthIncludedDayTrigger\u3002\u8fd9\u56db\u79cd trigger \u53ef\u4ee5\u6ee1\u8db3\u4f01\u4e1a\u5e94\u7528\u4e2d\u7684\u7edd\u5927\u90e8\u5206\u9700\u6c42\u3002\u6211\u4eec\u5c06\u5728\u4f01\u4e1a\u5e94\u7528\u4e00\u8282\u4e2d\u8fdb\u4e00\u6b65\u8ba8\u8bba\u56db\u79cd trigger \u7684\u529f\u80fd\u3002<\/p>\n

      \u5728 Quartz \u4e2d\uff0cjob \u7528\u4e8e\u8868\u793a\u88ab\u8c03\u5ea6\u7684\u4efb\u52a1\u3002\u4e3b\u8981\u6709\u4e24\u79cd\u7c7b\u578b\u7684 job\uff1a\u65e0\u72b6\u6001\u7684\uff08stateless\uff09\u548c\u6709\u72b6\u6001\u7684\uff08stateful\uff09\u3002\u5bf9\u4e8e\u540c\u4e00\u4e2a trigger \u6765\u8bf4\uff0c\u6709\u72b6\u6001\u7684 job \u4e0d\u80fd\u88ab\u5e76\u884c\u6267\u884c\uff0c\u53ea\u6709\u4e0a\u4e00\u6b21\u89e6\u53d1\u7684\u4efb\u52a1\u88ab\u6267\u884c\u5b8c\u4e4b\u540e\uff0c\u624d\u80fd\u89e6\u53d1\u4e0b\u4e00\u6b21\u6267\u884c\u3002Job \u4e3b\u8981\u6709\u4e24\u79cd\u5c5e\u6027\uff1avolatility \u548c durability\uff0c\u5176\u4e2d volatility \u8868\u793a\u4efb\u52a1\u662f\u5426\u88ab\u6301\u4e45\u5316\u5230\u6570\u636e\u5e93\u5b58\u50a8\uff0c\u800c durability \u8868\u793a\u5728\u6ca1\u6709 trigger \u5173\u8054\u7684\u65f6\u5019\u4efb\u52a1\u662f\u5426\u88ab\u4fdd\u7559\u3002\u4e24\u8005\u90fd\u662f\u5728\u503c\u4e3a true \u7684\u65f6\u5019\u4efb\u52a1\u88ab\u6301\u4e45\u5316\u6216\u4fdd\u7559\u3002\u4e00\u4e2a job \u53ef\u4ee5\u88ab\u591a\u4e2a trigger \u5173\u8054\uff0c\u4f46\u662f\u4e00\u4e2a trigger \u53ea\u80fd\u5173\u8054\u4e00\u4e2a job\u3002<\/p>\n

      \u5728 Quartz \u4e2d\uff0c scheduler \u7531 scheduler \u5de5\u5382\u521b\u5efa\uff1aDirectSchedulerFactory \u6216\u8005 StdSchedulerFactory\u3002 \u7b2c\u4e8c\u79cd\u5de5\u5382 StdSchedulerFactory \u4f7f\u7528\u8f83\u591a\uff0c\u56e0\u4e3a DirectSchedulerFactory \u4f7f\u7528\u8d77\u6765\u4e0d\u591f\u65b9\u4fbf\uff0c\u9700\u8981\u4f5c\u8bb8\u591a\u8be6\u7ec6\u7684\u624b\u5de5\u7f16\u7801\u8bbe\u7f6e\u3002 Scheduler \u4e3b\u8981\u6709\u4e09\u79cd\uff1aRemoteMBeanScheduler\uff0c RemoteScheduler \u548c StdScheduler\u3002\u672c\u6587\u4ee5\u6700\u5e38\u7528\u7684 StdScheduler \u4e3a\u4f8b\u8bb2\u89e3\u3002\u8fd9\u4e5f\u662f\u7b14\u8005\u5728\u9879\u76ee\u4e2d\u6240\u4f7f\u7528\u7684 scheduler \u7c7b\u3002<\/p>\n

      Quartz \u6838\u5fc3\u5143\u7d20\u4e4b\u95f4\u7684\u5173\u7cfb\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n

      \u56fe 1. Quartz \u6838\u5fc3\u5143\u7d20\u5173\u7cfb\u56fe<\/p>\n

      \"quartz\u539f\u7406\u5206\u6790_\u5355\u7247\u673a\u5b9a\u65f6\u5668\u539f\u7406[\u901a\u4fd7\u6613\u61c2]<\/p>\n

      \u7ebf\u7a0b\u89c6\u56fe<\/strong><\/p>\n

      \u5728 Quartz \u4e2d\uff0c\u6709\u4e24\u7c7b\u7ebf\u7a0b\uff0cScheduler \u8c03\u5ea6\u7ebf\u7a0b\u548c\u4efb\u52a1\u6267\u884c\u7ebf\u7a0b\uff0c\u5176\u4e2d\u4efb\u52a1\u6267\u884c\u7ebf\u7a0b\u901a\u5e38\u4f7f\u7528\u4e00\u4e2a\u7ebf\u7a0b\u6c60\u7ef4\u62a4\u4e00\u7ec4\u7ebf\u7a0b\u3002<\/p>\n

      \u56fe 2. Quartz \u7ebf\u7a0b\u89c6\u56fe<\/p>\n

      \"quartz\u539f\u7406\u5206\u6790_\u5355\u7247\u673a\u5b9a\u65f6\u5668\u539f\u7406[\u901a\u4fd7\u6613\u61c2]<\/p>\n

      Scheduler \u8c03\u5ea6\u7ebf\u7a0b\u4e3b\u8981\u6709\u4e24\u4e2a\uff1a \u6267\u884c\u5e38\u89c4\u8c03\u5ea6\u7684\u7ebf\u7a0b\uff0c\u548c\u6267\u884c misfired trigger \u7684\u7ebf\u7a0b\u3002\u5e38\u89c4\u8c03\u5ea6\u7ebf\u7a0b\u8f6e\u8be2\u5b58\u50a8\u7684\u6240\u6709 trigger\uff0c\u5982\u679c\u6709\u9700\u8981\u89e6\u53d1\u7684 trigger\uff0c\u5373\u5230\u8fbe\u4e86\u4e0b\u4e00\u6b21\u89e6\u53d1\u7684\u65f6\u95f4\uff0c\u5219\u4ece\u4efb\u52a1\u6267\u884c\u7ebf\u7a0b\u6c60\u83b7\u53d6\u4e00\u4e2a\u7a7a\u95f2\u7ebf\u7a0b\uff0c\u6267\u884c\u4e0e\u8be5 trigger \u5173\u8054\u7684\u4efb\u52a1\u3002Misfire \u7ebf\u7a0b\u662f\u626b\u63cf\u6240\u6709\u7684 trigger\uff0c\u67e5\u770b\u662f\u5426\u6709 misfired trigger\uff0c\u5982\u679c\u6709\u7684\u8bdd\u6839\u636e misfire \u7684\u7b56\u7565\u5206\u522b\u5904\u7406\u3002\u4e0b\u56fe\u63cf\u8ff0\u4e86\u8fd9\u4e24\u4e2a\u7ebf\u7a0b\u7684\u57fa\u672c\u6d41\u7a0b\uff1a<\/p>\n

      \u56fe 3. Quartz \u8c03\u5ea6\u7ebf\u7a0b\u6d41\u7a0b\u56fe<\/p>\n

      \"quartz\u539f\u7406\u5206\u6790_\u5355\u7247\u673a\u5b9a\u65f6\u5668\u539f\u7406[\u901a\u4fd7\u6613\u61c2]<\/p>\n

      \u5173\u4e8e misfired trigger\uff0c\u6211\u4eec\u5728\u4f01\u4e1a\u5e94\u7528\u4e00\u8282\u4e2d\u5c06\u8fdb\u4e00\u6b65\u63cf\u8ff0\u3002<\/p>\n

      \u6570\u636e\u5b58\u50a8<\/strong><\/p>\n

      Quartz \u4e2d\u7684 trigger \u548c job \u9700\u8981\u5b58\u50a8\u4e0b\u6765\u624d\u80fd\u88ab\u4f7f\u7528\u3002Quartz \u4e2d\u6709\u4e24\u79cd\u5b58\u50a8\u65b9\u5f0f\uff1aRAMJobStore, JobStoreSupport\uff0c\u5176\u4e2d RAMJobStore \u662f\u5c06 trigger \u548c job \u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u800c JobStoreSupport \u662f\u57fa\u4e8e jdbc \u5c06 trigger \u548c job \u5b58\u50a8\u5230\u6570\u636e\u5e93\u4e2d\u3002RAMJobStore \u7684\u5b58\u53d6\u901f\u5ea6\u975e\u5e38\u5feb\uff0c\u4f46\u662f\u7531\u4e8e\u5176\u5728\u7cfb\u7edf\u88ab\u505c\u6b62\u540e\u6240\u6709\u7684\u6570\u636e\u90fd\u4f1a\u4e22\u5931\uff0c\u6240\u4ee5\u5728\u901a\u5e38\u5e94\u7528\u4e2d\uff0c\u90fd\u662f\u4f7f\u7528 JobStoreSupport\u3002<\/p>\n

      \u5728 Quartz \u4e2d\uff0cJobStoreSupport \u4f7f\u7528\u4e00\u4e2a\u9a71\u52a8\u4ee3\u7406\u6765\u64cd\u4f5c trigger \u548c job \u7684\u6570\u636e\u5b58\u50a8\uff1aStdJDBCDelegate\u3002StdJDBCDelegate \u5b9e\u73b0\u4e86\u5927\u90e8\u5206\u57fa\u4e8e\u6807\u51c6 JDBC \u7684\u529f\u80fd\u63a5\u53e3\uff0c\u4f46\u662f\u5bf9\u4e8e\u5404\u79cd\u6570\u636e\u5e93\u6765\u8bf4\uff0c\u9700\u8981\u6839\u636e\u5176\u5177\u4f53\u5b9e\u73b0\u7684\u7279\u70b9\u505a\u67d0\u4e9b\u7279\u6b8a\u5904\u7406\uff0c\u56e0\u6b64\u5404\u79cd\u6570\u636e\u5e93\u9700\u8981\u6269\u5c55 StdJDBCDelegate \u4ee5\u5b9e\u73b0\u8fd9\u4e9b\u7279\u6b8a\u5904\u7406\u3002Quartz \u5df2\u7ecf\u81ea\u5e26\u4e86\u4e00\u4e9b\u6570\u636e\u5e93\u7684\u6269\u5c55\u5b9e\u73b0\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n

      \u56fe 4. Quartz \u6570\u636e\u5e93\u9a71\u52a8\u4ee3\u7406<\/p>\n

      \"quartz\u539f\u7406\u5206\u6790_\u5355\u7247\u673a\u5b9a\u65f6\u5668\u539f\u7406[\u901a\u4fd7\u6613\u61c2]<\/p>\n

      \u4f5c\u4e3a\u5d4c\u5165\u5f0f\u6570\u636e\u5e93\u7684\u4ee3\u8868\uff0cDerby \u8fd1\u6765\u975e\u5e38\u6d41\u884c\u3002\u5982\u679c\u4f7f\u7528 Derby \u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0a\u56fe\u4e2d\u7684 CloudscapeDelegate \u4f5c\u4e3a trigger \u548c job \u6570\u636e\u5b58\u50a8\u7684\u4ee3\u7406\u7c7b\u3002<\/p>\n

      <\/span><\/p>\n

         2.2 quartz\u542f\u52a8\u6d41\u7a0b<\/h3>\n

         <\/p>\n

      \u82e5quartz\u662f\u914d\u7f6e\u5728spring\u4e2d\uff0c\u5f53\u670d\u52a1\u5668\u542f\u52a8\u65f6\uff0c\u5c31\u4f1a\u88c5\u8f7d\u76f8\u5173\u7684bean\u3002SchedulerFactoryBean\u5b9e\u73b0\u4e86InitializingBean\u63a5\u53e3\uff0c\u56e0\u6b64\u5728\u521d\u59cb\u5316bean\u7684\u65f6\u5019\uff0c\u4f1a\u6267\u884cafterPropertiesSet\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u5c06\u4f1a\u8c03\u7528SchedulerFactory(DirectSchedulerFactory \u6216\u8005 StdSchedulerFactory\uff0c\u901a\u5e38\u7528StdSchedulerFactory)\u521b\u5efaScheduler\u3002SchedulerFactory\u5728\u521b\u5efaquartzScheduler\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5c06\u4f1a\u8bfb\u53d6\u914d\u7f6e\u53c2\u6570\uff0c\u521d\u59cb\u5316\u5404\u4e2a\u7ec4\u4ef6\uff0c\u5173\u952e\u7ec4\u4ef6\u5982\u4e0b\uff1a<\/p>\n

        \n
      1. \n

        ThreadPool<\/strong>:\u4e00\u822c\u662f\u4f7f\u7528SimpleThreadPool,SimpleThreadPool\u521b\u5efa\u4e86\u4e00\u5b9a\u6570\u91cf\u7684WorkerThread\u5b9e\u4f8b\u6765\u4f7f\u5f97Job\u80fd\u591f\u5728\u7ebf\u7a0b\u4e2d\u8fdb\u884c\u5904\u7406\u3002WorkerThread\u662f\u5b9a\u4e49\u5728SimpleThreadPool\u7c7b\u4e2d\u7684\u5185\u90e8\u7c7b\uff0c\u5b83\u5b9e\u8d28\u4e0a\u5c31\u662f\u4e00\u4e2a\u7ebf\u7a0b\u3002\u5728SimpleThreadPool\u4e2d\u6709\u4e09\u4e2alist\uff1aworkers-\u5b58\u653e\u6c60\u4e2d\u6240\u6709\u7684\u7ebf\u7a0b\u5f15\u7528\uff0cavailWorkers-\u5b58\u653e\u6240\u6709\u7a7a\u95f2\u7684\u7ebf\u7a0b\uff0cbusyWorkers-\u5b58\u653e\u6240\u6709\u5de5\u4f5c\u4e2d\u7684\u7ebf\u7a0b\uff1b
        \u7ebf\u7a0b\u6c60\u7684\u914d\u7f6e\u53c2\u6570\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n
        \n
        1\n2\n3<\/pre>\n<\/td>\n
        \n
        org.quartz.threadPool.class<\/span>=org.quartz.simpl.SimpleThreadPool\norg.quartz.threadPool.threadCount=3<\/span>\norg.quartz.threadPool.threadPriority=5<\/span><\/code>\n       \n       \n       \n       
          \n \n
        • 1<\/li>\n \n
        • 2<\/li>\n \n <\/ul><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n
        • \n

          JobStore<\/strong>:\u5206\u4e3a\u5b58\u50a8\u5728\u5185\u5b58\u7684RAMJobStore\u548c\u5b58\u50a8\u5728\u6570\u636e\u5e93\u7684JobStoreSupport(\u5305\u62ecJobStoreTX\u548cJobStoreCMT\u4e24\u79cd\u5b9e\u73b0\uff0cJobStoreCMT\u662f\u4f9d\u8d56\u4e8e\u5bb9\u5668\u6765\u8fdb\u884c\u4e8b\u52a1\u7684\u7ba1\u7406\uff0c\u800cJobStoreTX\u662f\u81ea\u5df1\u7ba1\u7406\u4e8b\u52a1\uff09\uff0c\u82e5\u8981\u4f7f\u7528\u96c6\u7fa4\u8981\u4f7f\u7528JobStoreSupport\u7684\u65b9\u5f0f\uff1b<\/p>\n<\/li>\n

        • QuartzSchedulerThread<\/strong>:\u7528\u6765\u8fdb\u884c\u4efb\u52a1\u8c03\u5ea6\u7684\u7ebf\u7a0b\uff0c\u5728\u521d\u59cb\u5316\u7684\u65f6\u5019paused=true,halted=false,\u867d\u7136\u7ebf\u7a0b\u5f00\u59cb\u8fd0\u884c\u4e86\uff0c\u4f46\u662fpaused=true\uff0c\u7ebf\u7a0b\u4f1a\u4e00\u76f4\u7b49\u5f85\uff0c\u76f4\u5230start\u65b9\u6cd5\u5c06paused\u7f6e\u4e3afalse\uff1b<\/li>\n<\/ol>\n

          \u53e6\u5916\uff0cSchedulerFactoryBean\u8fd8\u5b9e\u73b0\u4e86SmartLifeCycle\u63a5\u53e3\uff0c\u56e0\u6b64\u521d\u59cb\u5316\u5b8c\u6210\u540e\uff0c\u4f1a\u6267\u884cstart()\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u5c06\u4e3b\u8981\u4f1a\u6267\u884c\u4ee5\u4e0b\u7684\u51e0\u4e2a\u52a8\u4f5c\uff1a<\/p>\n

            \n
          1. \u521b\u5efaClusterManager<\/strong>\u7ebf\u7a0b\u5e76\u542f\u52a8\u7ebf\u7a0b:\u8be5\u7ebf\u7a0b\u7528\u6765\u8fdb\u884c\u96c6\u7fa4\u6545\u969c\u68c0\u6d4b\u548c\u5904\u7406\uff0c\u5c06\u5728\u4e0b\u6587\u8be6\u7ec6\u8ba8\u8bba\uff1b<\/li>\n
          2. \u521b\u5efaMisfireHandler<\/strong>\u7ebf\u7a0b\u5e76\u542f\u52a8\u7ebf\u7a0b:\u8be5\u7ebf\u7a0b\u7528\u6765\u8fdb\u884cmisfire\u4efb\u52a1\u7684\u5904\u7406\uff0c\u5c06\u5728\u4e0b\u6587\u8be6\u7ec6\u8ba8\u8bba\uff1b<\/li>\n
          3. \u7f6eQuartzSchedulerThread\u7684paused=false\uff0c\u8c03\u5ea6\u7ebf\u7a0b\u624d\u771f\u6b63\u5f00\u59cb\u8c03\u5ea6\uff1b<\/li>\n<\/ol>\n

            \u6574\u4e2a\u542f\u52a8\u6d41\u7a0b\u5982\u4e0b\u56fe\uff1a <\/p>\n

             <\/p>\n

            <\/span><\/p>\n

             \u4e09\u3001Spring + Quartz \u5b9e\u73b0\u4f01\u4e1a\u7ea7\u8c03\u5ea6\u7684\u5b9e\u73b0\u793a\u4f8b<\/h2>\n

            <\/span><\/p>\n

            3.1 \u73af\u5883\u4fe1\u606f<\/h3>\n

               \u6b64\u793a\u4f8b\u4e2d\u7684\u73af\u5883\uff1a Spring 4.1.6.RELEASE   + quartz 2.2.1 + Mysql 5.6<\/p>\n

            <\/span><\/p>\n

            3.2 \u76f8\u5173\u4ee3\u7801\u53ca\u914d\u7f6e<\/h3>\n

            <\/span><\/p>\n

               3.2.1 Maven \u5f15\u5165<\/h4>\n

                   \"quartz\u539f\u7406\u5206\u6790_\u5355\u7247\u673a\u5b9a\u65f6\u5668\u539f\u7406[\u901a\u4fd7\u6613\u61c2]<\/p>\n

            <\/span><\/p>\n

             3.2.2 \u6570\u636e\u5e93\u811a\u672c\u51c6\u5907<\/h4>\n

                <\/p>\n

            SET FOREIGN_KEY_CHECKS=0;<\/p>\n

            \u2013 \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-
            \u2013 Table structure for task_schedule_job
            \u2013 \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-
            DROP TABLE IF EXISTS `task_schedule_job`;
            CREATE TABLE `task_schedule_job` (
              `job_id` bigint(20) NOT NULL AUTO_INCREMENT,
              `create_time` timestamp NULL DEFAULT NULL,
              `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
              `job_name` varchar(255) DEFAULT NULL,
              `job_group` varchar(255) DEFAULT NULL,
              `job_status` varchar(255) DEFAULT NULL,
              `cron_expression` varchar(255) NOT NULL,
              `description` varchar(255) DEFAULT NULL,
              `bean_class` varchar(255) DEFAULT NULL,
              `is_concurrent` varchar(255) DEFAULT NULL COMMENT \u20181\u2019,
              `spring_id` varchar(255) DEFAULT NULL,
              `method_name` varchar(255) NOT NULL
              PRIMARY KEY (`job_id`),
              UNIQUE KEY `name_group` (`job_name`,`job_group`) USING BTREE
            ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;<\/p>\n

             <\/p>\n

            \u5728Quartz\u5305\u4e0bdocs\/dbTables\uff0c\u9009\u62e9\u5bf9\u5e94\u7684\u6570\u636e\u5e93\u811a\u672c\uff0c\u521b\u5efa\u76f8\u5e94\u7684\u6570\u636e\u5e93\u8868\u5373\u53ef\uff0c\u6211\u7528\u7684\u662fmysql5.6\uff0c\u8fd9\u91cc\u6709\u4e00\u4e2a\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\uff0cmysql5.5\u4e4b\u524d\u7528\u7684\u8868\u5b58\u50a8\u5f15\u64ce\u662fMyISAM\uff0c\u4f7f\u7528\u7684\u662f\u8868\u7ea7\u9501\uff0c\u9501\u53d1\u751f\u51b2\u7a81\u7684\u6982\u7387\u6bd4\u8f83\u9ad8\uff0c\u5e76\u53d1\u5ea6\u4f4e\uff1b5.6\u4e4b\u540e\u9ed8\u8ba4\u7684\u5b58\u50a8\u5f15\u64ce\u4e3aInnoDB,InnoDB\u91c7\u7528\u7684\u9501\u673a\u5236\u662f\u884c\u7ea7\u9501\uff0c\u5e76\u53d1\u5ea6\u4e5f\u8f83\u9ad8\u3002\u800cquartz\u96c6\u7fa4\u4f7f\u7528\u6570\u636e\u5e93\u9501\u7684<\/p>\n

            \u673a\u5236\u6765\u6765\u5b9e\u73b0\u540c\u4e00\u4e2a\u4efb\u52a1\u5728\u540c\u4e00\u4e2a\u65f6\u523b\u53ea\u88ab\u5b9e\u4f8b\u6267\u884c\uff0c\u6240\u4ee5\u4e3a\u4e86\u9632\u6b62\u51b2\u7a81\uff0c\u6211\u4eec\u5efa\u8868\u7684\u65f6\u5019\u8981\u9009\u53d6InnoDB\u4f5c\u4e3a\u8868\u7684\u5b58<\/p>\n

            \u50a8\u5f15\u64ce\u3002\u5982\u4e0b\uff1a<\/p>\n

             <\/p>\n

                  \"quartz\u539f\u7406\u5206\u6790_\u5355\u7247\u673a\u5b9a\u65f6\u5668\u539f\u7406[\u901a\u4fd7\u6613\u61c2]<\/p>\n

            <\/span><\/p>\n

             3.2.3 \u5173\u952e\u4ee3\u7801\u53ca\u914d\u7f6e<\/h4>\n

               <1>spring-quartz.xml \u914d\u7f6e \u5728application.xml \u6587\u4ef6\u4e2d\u5f15\u5165<\/p>\n

            <?<\/span>xml version=\"1.0\"<\/span> encoding=\"UTF-8\"<\/span>?><\/span><\/span>\n<beans<\/span> xmlns<\/span>=\"http:\/\/www.springframework.org\/schema\/beans\"<\/span> xmlns:xsi<\/span>=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"<\/span>\n       xsi:schemaLocation<\/span>=\" http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.0.xsd\"<\/span>><\/span>\n\n    <!-- \u6ce8\u518c\u672c\u5730\u8c03\u5ea6\u4efb\u52a1\n    <bean id=\"localQuartzScheduler\" class=\"org.springframework.scheduling.quartz.SchedulerFactoryBean\"><\/bean>--><\/span>\n\n    <!-- \u6ce8\u518c\u96c6\u7fa4\u8c03\u5ea6\u4efb\u52a1 --><\/span>\n    <bean<\/span> id<\/span>=\"schedulerFactoryBean\"<\/span> lazy-init<\/span>=\"false\"<\/span> autowire<\/span>=\"no\"<\/span>\n          class<\/span>=\"org.springframework.scheduling.quartz.SchedulerFactoryBean\"<\/span> destroy-method<\/span>=\"destroy\"<\/span>><\/span>\n        <!--\u53ef\u9009\uff0cQuartzScheduler \u542f\u52a8\u65f6\u66f4\u65b0\u5df1\u5b58\u5728\u7684Job\uff0c\u8fd9\u6837\u5c31\u4e0d\u7528\u6bcf\u6b21\u4fee\u6539targetObject\u540e\u5220\u9664qrtz_job_details\u8868\u5bf9\u5e94\u8bb0\u5f55\u4e86 --><\/span>\n        <property<\/span> name<\/span>=\"overwriteExistingJobs\"<\/span> value<\/span>=\"true\"<\/span> \/><\/span>\n        <!--\u5fc5\u987b\u7684\uff0cQuartzScheduler \u5ef6\u65f6\u542f\u52a8\uff0c\u5e94\u7528\u542f\u52a8\u5b8c\u540e QuartzScheduler \u518d\u542f\u52a8 --><\/span>\n        <property<\/span> name<\/span>=\"startupDelay\"<\/span> value<\/span>=\"3\"<\/span> \/><\/span>\n        <!-- \u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8 --><\/span>\n        <property<\/span> name<\/span>=\"autoStartup\"<\/span> value<\/span>=\"true\"<\/span> \/><\/span>\n        <property<\/span> name<\/span>=\"applicationContextSchedulerContextKey\"<\/span> value<\/span>=\"applicationContext\"<\/span> \/><\/span>\n        <property<\/span> name<\/span>=\"configLocation\"<\/span> value<\/span>=\"classpath:quartz.properties\"<\/span> \/><\/span>\n    <\/bean<\/span>><\/span>\n\n<\/beans<\/span>><\/span><\/pre>\n

            <2>quartz.properties \u6587\u4ef6\u914d\u7f6e<\/p>\n

            #==============================================================<\/span>\n#Configure Main Scheduler Properties<\/span>\n#==============================================================<\/span>\norg.quartz.scheduler.instanceName = KuanrfGSQuartzScheduler\norg.quartz.scheduler.instanceId = AUTO\n\n#==============================================================<\/span>\n#Configure JobStore<\/span>\n#==============================================================<\/span>\norg.quartz.jobStore.class<\/span> = org.quartz.impl.jdbcjobstore.JobStoreTX\norg.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate\norg.quartz.jobStore.tablePrefix = QRTZ_<\/span>\norg.quartz.jobStore.isClustered = true<\/span>\norg.quartz.jobStore.clusterCheckinInterval = 20000<\/span>\norg.quartz.jobStore.dataSource = myDS\norg.quartz.jobStore.maxMisfiresToHandleAtATime = 1<\/span>\norg.quartz.jobStore.misfireThreshold = 120000<\/span>\norg.quartz.jobStore.txIsolationLevelSerializable = false<\/span>\n\n#==============================================================<\/span>\n#Configure DataSource<\/span>\n#==============================================================<\/span>\norg.quartz.dataSource.myDS.driver = com.mysql.jdbc.Driver\norg.quartz.dataSource.myDS.URL = \u4f60\u7684\u6570\u636e\u94fe\u63a5\norg.quartz.dataSource.myDS.user = \u7528\u6237\u540d\norg.quartz.dataSource.myDS.password = \u5bc6\u7801\norg.quartz.dataSource.myDS.maxConnections = 30<\/span>\norg.quartz.jobStore.selectWithLockSQL = SELECT * FROM {\n  \n  0<\/span>}LOCKS WHERE LOCK_NAME = ? FOR UPDATE\n\n#==============================================================<\/span>\n#Configure ThreadPool<\/span>\n#==============================================================<\/span>\norg.quartz.threadPool.class<\/span>= org.quartz.simpl.SimpleThreadPool\norg.quartz.threadPool.threadCount= 10<\/span>\norg.quartz.threadPool.threadPriority= 5<\/span>\norg.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread= true<\/span>\n\n#==============================================================<\/span>\n#Skip Check Update<\/span>\n#update:true<\/span>\n#not update:false<\/span>\n#==============================================================<\/span>\norg.quartz.scheduler.skipUpdateCheck = true<\/span>\n\n#============================================================================<\/span>\n# Configure Plugins<\/span>\n#============================================================================<\/span>\norg.quartz.plugin.triggHistory.class<\/span> = org.quartz.plugins.history.LoggingJobHistoryPlugin\norg.quartz.plugin.shutdownhook.class<\/span> = org.quartz.plugins.management.ShutdownHookPlugin\norg.quartz.plugin.shutdownhook.cleanShutdown = true<\/span><\/code>\n \n \n \n 
              \n \n
            • 1<\/li>\n \n
            • 2<\/li>\n \n
            • 3<\/li>\n \n
            • 4<\/li>\n \n
            • 5<\/li>\n \n
            • 6<\/li>\n \n
            • 7<\/li>\n \n
            • 8<\/li>\n \n
            • 9<\/li>\n \n
            • 10<\/li>\n \n
            • 11<\/li>\n \n
            • 12<\/li>\n \n
            • 13<\/li>\n \n
            • 14<\/li>\n \n
            • 15<\/li>\n \n
            • 16<\/li>\n \n
            • 17<\/li>\n \n
            • 18<\/li>\n \n
            • 19<\/li>\n \n
            • 20<\/li>\n \n
            • 21<\/li>\n \n
            • 22<\/li>\n \n
            • 23<\/li>\n \n
            • 24<\/li>\n \n
            • 25<\/li>\n \n
            • 26<\/li>\n \n
            • 27<\/li>\n \n
            • 28<\/li>\n \n
            • 29<\/li>\n \n
            • 30<\/li>\n \n
            • 31<\/li>\n \n
            • 32<\/li>\n \n
            • 33<\/li>\n \n
            • 34<\/li>\n \n
            • 35<\/li>\n \n
            • 36<\/li>\n \n
            • 37<\/li>\n \n
            • 38<\/li>\n \n
            • 39<\/li>\n \n
            • 40<\/li>\n \n
            • 41<\/li>\n \n
            • 42<\/li>\n \n
            • 43<\/li>\n \n
            • 44<\/li>\n \n
            • 45<\/li>\n \n
            • 46<\/li>\n \n
            • 47<\/li>\n \n
            • 48<\/li>\n \n
            • 49<\/li>\n \n <\/ul><\/pre>\n

              <3>\u5173\u952e\u4ee3\u7801<\/p>\n

              package<\/span> com.netease.ad.omp.service.sys;\n\nimport<\/span> java.util.ArrayList;\nimport<\/span> java.util.Date;\nimport<\/span> java.util.List;\nimport<\/span> java.util.Set;\n\nimport<\/span> javax.annotation.PostConstruct;\nimport<\/span> javax.annotation.Resource;\n\nimport<\/span> com.netease.ad.omp.common.utils.SpringUtils;\nimport<\/span> com.netease.ad.omp.dao.sys.mapper.ScheduleJobMapper;\nimport<\/span> com.netease.ad.omp.entity.sys.ScheduleJob;\nimport<\/span> com.netease.ad.omp.quartz.job.JobUtils;\nimport<\/span> com.netease.ad.omp.quartz.job.MyDetailQuartzJobBean;\nimport<\/span> com.netease.ad.omp.quartz.job.QuartzJobFactory;\nimport<\/span> com.netease.ad.omp.quartz.job.QuartzJobFactoryDisallowConcurrentExecution;\nimport<\/span> org.apache.log4j.Logger;\nimport<\/span> org.quartz.CronScheduleBuilder;\nimport<\/span> org.quartz.CronTrigger;\nimport<\/span> org.quartz.JobBuilder;\nimport<\/span> org.quartz.JobDetail;\nimport<\/span> org.quartz.JobExecutionContext;\nimport<\/span> org.quartz.JobKey;\nimport<\/span> org.quartz.Scheduler;\nimport<\/span> org.quartz.SchedulerException;\nimport<\/span> org.quartz.Trigger;\nimport<\/span> org.quartz.TriggerBuilder;\nimport<\/span> org.quartz.TriggerKey;\nimport<\/span> org.quartz.impl.matchers.GroupMatcher;\nimport<\/span> org.springframework.beans.factory.annotation.Autowired;\nimport<\/span> org.springframework.scheduling.quartz.SchedulerFactoryBean;\nimport<\/span> org.springframework.stereotype.Service;\n\n\n\/** * \u8ba1\u5212\u4efb\u52a1\u7ba1\u7406 *\/<\/span>\n@Service<\/span>\npublic<\/span> class<\/span> JobTaskService<\/span> <\/span>{\n   public<\/span> final<\/span> Logger log = Logger.getLogger(this<\/span>.getClass());\n   @Autowired<\/span>\n   private<\/span> SchedulerFactoryBean schedulerFactoryBean;\n\n   @Autowired<\/span>\n   private<\/span> ScheduleJobMapper scheduleJobMapper;\n\n\n   \/** * \u4ece\u6570\u636e\u5e93\u4e2d\u53d6 \u533a\u522b\u4e8egetAllJob * * @return<\/span> *\/<\/span>\n   public<\/span> List<ScheduleJob> getAllTask<\/span>()<\/span> <\/span>{\n      return<\/span> scheduleJobMapper.select(null<\/span>);\n   }\n\n   \/** * \u6dfb\u52a0\u5230\u6570\u636e\u5e93\u4e2d \u533a\u522b\u4e8eaddJob *\/<\/span>\n   public<\/span> void<\/span> addTask<\/span>(ScheduleJob job)<\/span> <\/span>{\n      job.setCreateTime(new<\/span> Date());\n      scheduleJobMapper.insertSelective(job);\n   }\n\n   \/** * \u4ece\u6570\u636e\u5e93\u4e2d\u67e5\u8be2job *\/<\/span>\n   public<\/span> ScheduleJob getTaskById<\/span>(Long jobId)<\/span> <\/span>{\n      return<\/span> scheduleJobMapper.selectByPrimaryKey(jobId);\n   }\n\n   \/** * \u66f4\u6539\u4efb\u52a1\u72b6\u6001 * * @throws<\/span> SchedulerException *\/<\/span>\n   public<\/span> void<\/span> changeStatus<\/span>(Long jobId, String cmd)<\/span> throws<\/span> SchedulerException <\/span>{\n      ScheduleJob job = getTaskById(jobId);\n      if<\/span> (job == null<\/span>) {\n         return<\/span>;\n      }\n      if<\/span> (\"stop\"<\/span>.equals(cmd)) {\n         deleteJob(job);\n         job.setJobStatus(JobUtils.STATUS_NOT_RUNNING);\n      } else<\/span> if<\/span> (\"start\"<\/span>.equals(cmd)) {\n         job.setJobStatus(JobUtils.STATUS_RUNNING);\n         addJob(job);\n      }\n      scheduleJobMapper.updateByPrimaryKeySelective(job);\n   }\n\n   \/** * \u66f4\u6539\u4efb\u52a1 cron\u8868\u8fbe\u5f0f * * @throws<\/span> SchedulerException *\/<\/span>\n   public<\/span> void<\/span> updateCron<\/span>(Long jobId, String cron)<\/span> throws<\/span> SchedulerException <\/span>{\n      ScheduleJob job = getTaskById(jobId);\n      if<\/span> (job == null<\/span>) {\n         return<\/span>;\n      }\n      job.setCronExpression(cron);\n      if<\/span> (JobUtils.STATUS_RUNNING.equals(job.getJobStatus())) {\n         updateJobCron(job);\n      }\n      scheduleJobMapper.updateByPrimaryKeySelective(job);\n   }\n\n   \/** * \u6dfb\u52a0\u4efb\u52a1 * * @throws<\/span> SchedulerException *\/<\/span>\n   public<\/span> void<\/span> addJob<\/span>(ScheduleJob job)<\/span> throws<\/span> SchedulerException <\/span>{\n      if<\/span> (job == null<\/span> || !JobUtils.STATUS_RUNNING.equals(job.getJobStatus())) {\n         return<\/span>;\n      }\n      Scheduler scheduler = schedulerFactoryBean.getScheduler();\n      log.debug(scheduler + \".......................................................................................add\"<\/span>);\n      TriggerKey triggerKey = TriggerKey.triggerKey(job.getJobName(), job.getJobGroup());\n\n      CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);\n\n      \/\/ \u4e0d\u5b58\u5728\uff0c\u521b\u5efa\u4e00\u4e2a<\/span>\n      if<\/span> (null<\/span> == trigger) {\n         Class clazz = JobUtils.CONCURRENT_IS.equals(job.getIsConcurrent()) ? QuartzJobFactory.class : QuartzJobFactoryDisallowConcurrentExecution.class;\n         JobDetail jobDetail = JobBuilder.newJob(clazz).withIdentity(job.getJobName(), job.getJobGroup()).build();\n\n         jobDetail.getJobDataMap().put(\"scheduleJob\"<\/span>, job);\n\n         CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());\n\n         trigger = TriggerBuilder.newTrigger().withIdentity(job.getJobName(), job.getJobGroup()).withSchedule(scheduleBuilder).build();\n\n         scheduler.scheduleJob(jobDetail, trigger);\n      } else<\/span> {\n         \/\/ Trigger\u5df2\u5b58\u5728\uff0c\u90a3\u4e48\u66f4\u65b0\u76f8\u5e94\u7684\u5b9a\u65f6\u8bbe\u7f6e<\/span>\n         CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());\n\n         \/\/ \u6309\u65b0\u7684cronExpression\u8868\u8fbe\u5f0f\u91cd\u65b0\u6784\u5efatrigger<\/span>\n         trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();\n\n         \/\/ \u6309\u65b0\u7684trigger\u91cd\u65b0\u8bbe\u7f6ejob\u6267\u884c<\/span>\n         scheduler.rescheduleJob(triggerKey, trigger);\n      }\n   }\n\n   @PostConstruct<\/span>\n   public<\/span> void<\/span> init<\/span>()<\/span> throws<\/span> Exception <\/span>{\n\n      \/\/ \u8fd9\u91cc\u83b7\u53d6\u4efb\u52a1\u4fe1\u606f\u6570\u636e<\/span>\n      List<ScheduleJob> jobList = scheduleJobMapper.select(null<\/span>);\n\n      for<\/span> (ScheduleJob job : jobList) {\n         addJob(job);\n      }\n   }\n\n   \/** * \u83b7\u53d6\u6240\u6709\u8ba1\u5212\u4e2d\u7684\u4efb\u52a1\u5217\u8868 * * @return<\/span> * @throws<\/span> SchedulerException *\/<\/span>\n   public<\/span> List<ScheduleJob> getAllJob<\/span>()<\/span> throws<\/span> SchedulerException <\/span>{\n      Scheduler scheduler = schedulerFactoryBean.getScheduler();\n      GroupMatcher<JobKey> matcher = GroupMatcher.anyJobGroup();\n      Set<JobKey> jobKeys = scheduler.getJobKeys(matcher);\n      List<ScheduleJob> jobList = new<\/span> ArrayList<ScheduleJob>();\n      for<\/span> (JobKey jobKey : jobKeys) {\n         List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);\n         for<\/span> (Trigger trigger : triggers) {\n            ScheduleJob job = new<\/span> ScheduleJob();\n            job.setJobName(jobKey.getName());\n            job.setJobGroup(jobKey.getGroup());\n            job.setDescription(\"\u89e6\u53d1\u5668:\"<\/span> + trigger.getKey());\n            Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());\n            job.setJobStatus(triggerState.name());\n            if<\/span> (trigger instanceof<\/span> CronTrigger) {\n               CronTrigger cronTrigger = (CronTrigger) trigger;\n               String cronExpression = cronTrigger.getCronExpression();\n               job.setCronExpression(cronExpression);\n            }\n            jobList.add(job);\n         }\n      }\n      return<\/span> jobList;\n   }\n\n   \/** * \u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684job * * @return<\/span> * @throws<\/span> SchedulerException *\/<\/span>\n   public<\/span> List<ScheduleJob> getRunningJob<\/span>()<\/span> throws<\/span> SchedulerException <\/span>{\n      Scheduler scheduler = schedulerFactoryBean.getScheduler();\n      List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();\n      List<ScheduleJob> jobList = new<\/span> ArrayList<ScheduleJob>(executingJobs.size());\n      for<\/span> (JobExecutionContext executingJob : executingJobs) {\n         ScheduleJob job = new<\/span> ScheduleJob();\n         JobDetail jobDetail = executingJob.getJobDetail();\n         JobKey jobKey = jobDetail.getKey();\n         Trigger trigger = executingJob.getTrigger();\n         job.setJobName(jobKey.getName());\n         job.setJobGroup(jobKey.getGroup());\n         job.setDescription(\"\u89e6\u53d1\u5668:\"<\/span> + trigger.getKey());\n         Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());\n         job.setJobStatus(triggerState.name());\n         if<\/span> (trigger instanceof<\/span> CronTrigger) {\n            CronTrigger cronTrigger = (CronTrigger) trigger;\n            String cronExpression = cronTrigger.getCronExpression();\n            job.setCronExpression(cronExpression);\n         }\n         jobList.add(job);\n      }\n      return<\/span> jobList;\n   }\n\n   \/** * \u6682\u505c\u4e00\u4e2ajob * * @param<\/span> scheduleJob * @throws<\/span> SchedulerException *\/<\/span>\n   public<\/span> void<\/span> pauseJob<\/span>(ScheduleJob scheduleJob)<\/span> throws<\/span> SchedulerException <\/span>{\n      Scheduler scheduler = schedulerFactoryBean.getScheduler();\n      JobKey jobKey = JobKey.jobKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());\n      scheduler.pauseJob(jobKey);\n   }\n\n   \/** * \u6062\u590d\u4e00\u4e2ajob * * @param<\/span> scheduleJob * @throws<\/span> SchedulerException *\/<\/span>\n   public<\/span> void<\/span> resumeJob<\/span>(ScheduleJob scheduleJob)<\/span> throws<\/span> SchedulerException <\/span>{\n      Scheduler scheduler = schedulerFactoryBean.getScheduler();\n      JobKey jobKey = JobKey.jobKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());\n      scheduler.resumeJob(jobKey);\n   }\n\n   \/** * \u5220\u9664\u4e00\u4e2ajob * * @param<\/span> scheduleJob * @throws<\/span> SchedulerException *\/<\/span>\n   public<\/span> void<\/span> deleteJob<\/span>(ScheduleJob scheduleJob)<\/span> throws<\/span> SchedulerException <\/span>{\n      Scheduler scheduler = schedulerFactoryBean.getScheduler();\n      JobKey jobKey = JobKey.jobKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());\n      scheduler.deleteJob(jobKey);\n\n   }\n\n   \/** * \u7acb\u5373\u6267\u884cjob * * @param<\/span> scheduleJob * @throws<\/span> SchedulerException *\/<\/span>\n   public<\/span> void<\/span> runAJobNow<\/span>(ScheduleJob scheduleJob)<\/span> throws<\/span> SchedulerException <\/span>{\n      Scheduler scheduler = schedulerFactoryBean.getScheduler();\n      JobKey jobKey = JobKey.jobKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());\n      scheduler.triggerJob(jobKey);\n   }\n\n   \/** * \u66f4\u65b0job\u65f6\u95f4\u8868\u8fbe\u5f0f * * @param<\/span> scheduleJob * @throws<\/span> SchedulerException *\/<\/span>\n   public<\/span> void<\/span> updateJobCron<\/span>(ScheduleJob scheduleJob)<\/span> throws<\/span> SchedulerException <\/span>{\n      Scheduler scheduler = schedulerFactoryBean.getScheduler();\n\n      TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());\n\n      CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);\n\n      CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression());\n\n      trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();\n\n      scheduler.rescheduleJob(triggerKey, trigger);\n   }\n\n   public<\/span> static<\/span> void<\/span> main<\/span>(String[] args)<\/span> <\/span>{\n      CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(\"xxxxx\"<\/span>);\n   }\n}<\/code>\n \n \n \n 
                \n \n
              • 1<\/li>\n \n
              • 2<\/li>\n \n
              • 3<\/li>\n \n
              • 4<\/li>\n \n
              • 5<\/li>\n \n
              • 6<\/li>\n \n
              • 7<\/li>\n \n
              • 8<\/li>\n \n
              • 9<\/li>\n \n
              • 10<\/li>\n \n
              • 11<\/li>\n \n
              • 12<\/li>\n \n
              • 13<\/li>\n \n
              • 14<\/li>\n \n
              • 15<\/li>\n \n
              • 16<\/li>\n \n
              • 17<\/li>\n \n
              • 18<\/li>\n \n
              • 19<\/li>\n \n
              • 20<\/li>\n \n
              • 21<\/li>\n \n
              • 22<\/li>\n \n
              • 23<\/li>\n \n
              • 24<\/li>\n \n
              • 25<\/li>\n \n
              • 26<\/li>\n \n
              • 27<\/li>\n \n
              • 28<\/li>\n \n
              • 29<\/li>\n \n
              • 30<\/li>\n \n
              • 31<\/li>\n \n
              • 32<\/li>\n \n
              • 33<\/li>\n \n
              • 34<\/li>\n \n
              • 35<\/li>\n \n
              • 36<\/li>\n \n
              • 37<\/li>\n \n
              • 38<\/li>\n \n
              • 39<\/li>\n \n
              • 40<\/li>\n \n
              • 41<\/li>\n \n
              • 42<\/li>\n \n
              • 43<\/li>\n \n
              • 44<\/li>\n \n
              • 45<\/li>\n \n
              • 46<\/li>\n \n
              • 47<\/li>\n \n
              • 48<\/li>\n \n
              • 49<\/li>\n \n
              • 50<\/li>\n \n
              • 51<\/li>\n \n
              • 52<\/li>\n \n
              • 53<\/li>\n \n
              • 54<\/li>\n \n
              • 55<\/li>\n \n
              • 56<\/li>\n \n
              • 57<\/li>\n \n
              • 58<\/li>\n \n
              • 59<\/li>\n \n
              • 60<\/li>\n \n
              • 61<\/li>\n \n
              • 62<\/li>\n \n
              • 63<\/li>\n \n
              • 64<\/li>\n \n
              • 65<\/li>\n \n
              • 66<\/li>\n \n
              • 67<\/li>\n \n
              • 68<\/li>\n \n
              • 69<\/li>\n \n
              • 70<\/li>\n \n
              • 71<\/li>\n \n
              • 72<\/li>\n \n
              • 73<\/li>\n \n
              • 74<\/li>\n \n
              • 75<\/li>\n \n
              • 76<\/li>\n \n
              • 77<\/li>\n \n
              • 78<\/li>\n \n
              • 79<\/li>\n \n
              • 80<\/li>\n \n
              • 81<\/li>\n \n
              • 82<\/li>\n \n
              • 83<\/li>\n \n
              • 84<\/li>\n \n
              • 85<\/li>\n \n
              • 86<\/li>\n \n
              • 87<\/li>\n \n
              • 88<\/li>\n \n
              • 89<\/li>\n \n
              • 90<\/li>\n \n
              • 91<\/li>\n \n
              • 92<\/li>\n \n
              • 93<\/li>\n \n
              • 94<\/li>\n \n
              • 95<\/li>\n \n
              • 96<\/li>\n \n
              • 97<\/li>\n \n
              • 98<\/li>\n \n
              • 99<\/li>\n \n
              • 100<\/li>\n \n
              • 101<\/li>\n \n
              • 102<\/li>\n \n
              • 103<\/li>\n \n
              • 104<\/li>\n \n
              • 105<\/li>\n \n
              • 106<\/li>\n \n
              • 107<\/li>\n \n
              • 108<\/li>\n \n
              • 109<\/li>\n \n
              • 110<\/li>\n \n
              • 111<\/li>\n \n
              • 112<\/li>\n \n
              • 113<\/li>\n \n
              • 114<\/li>\n \n
              • 115<\/li>\n \n
              • 116<\/li>\n \n
              • 117<\/li>\n \n
              • 118<\/li>\n \n
              • 119<\/li>\n \n
              • 120<\/li>\n \n
              • 121<\/li>\n \n
              • 122<\/li>\n \n
              • 123<\/li>\n \n
              • 124<\/li>\n \n
              • 125<\/li>\n \n
              • 126<\/li>\n \n
              • 127<\/li>\n \n
              • 128<\/li>\n \n
              • 129<\/li>\n \n
              • 130<\/li>\n \n
              • 131<\/li>\n \n
              • 132<\/li>\n \n
              • 133<\/li>\n \n
              • 134<\/li>\n \n
              • 135<\/li>\n \n
              • 136<\/li>\n \n
              • 137<\/li>\n \n
              • 138<\/li>\n \n
              • 139<\/li>\n \n
              • 140<\/li>\n \n
              • 141<\/li>\n \n
              • 142<\/li>\n \n
              • 143<\/li>\n \n
              • 144<\/li>\n \n
              • 145<\/li>\n \n
              • 146<\/li>\n \n
              • 147<\/li>\n \n
              • 148<\/li>\n \n
              • 149<\/li>\n \n
              • 150<\/li>\n \n
              • 151<\/li>\n \n
              • 152<\/li>\n \n
              • 153<\/li>\n \n
              • 154<\/li>\n \n
              • 155<\/li>\n \n
              • 156<\/li>\n \n
              • 157<\/li>\n \n
              • 158<\/li>\n \n
              • 159<\/li>\n \n
              • 160<\/li>\n \n
              • 161<\/li>\n \n
              • 162<\/li>\n \n
              • 163<\/li>\n \n
              • 164<\/li>\n \n
              • 165<\/li>\n \n
              • 166<\/li>\n \n
              • 167<\/li>\n \n
              • 168<\/li>\n \n
              • 169<\/li>\n \n
              • 170<\/li>\n \n
              • 171<\/li>\n \n
              • 172<\/li>\n \n
              • 173<\/li>\n \n
              • 174<\/li>\n \n
              • 175<\/li>\n \n
              • 176<\/li>\n \n
              • 177<\/li>\n \n
              • 178<\/li>\n \n
              • 179<\/li>\n \n
              • 180<\/li>\n \n
              • 181<\/li>\n \n
              • 182<\/li>\n \n
              • 183<\/li>\n \n
              • 184<\/li>\n \n
              • 185<\/li>\n \n
              • 186<\/li>\n \n
              • 187<\/li>\n \n
              • 188<\/li>\n \n
              • 189<\/li>\n \n
              • 190<\/li>\n \n
              • 191<\/li>\n \n
              • 192<\/li>\n \n
              • 193<\/li>\n \n
              • 194<\/li>\n \n
              • 195<\/li>\n \n
              • 196<\/li>\n \n
              • 197<\/li>\n \n
              • 198<\/li>\n \n
              • 199<\/li>\n \n
              • 200<\/li>\n \n
              • 201<\/li>\n \n
              • 202<\/li>\n \n
              • 203<\/li>\n \n
              • 204<\/li>\n \n
              • 205<\/li>\n \n
              • 206<\/li>\n \n
              • 207<\/li>\n \n
              • 208<\/li>\n \n
              • 209<\/li>\n \n
              • 210<\/li>\n \n
              • 211<\/li>\n \n
              • 212<\/li>\n \n
              • 213<\/li>\n \n
              • 214<\/li>\n \n
              • 215<\/li>\n \n
              • 216<\/li>\n \n
              • 217<\/li>\n \n
              • 218<\/li>\n \n
              • 219<\/li>\n \n
              • 220<\/li>\n \n
              • 221<\/li>\n \n
              • 222<\/li>\n \n
              • 223<\/li>\n \n
              • 224<\/li>\n \n
              • 225<\/li>\n \n
              • 226<\/li>\n \n
              • 227<\/li>\n \n
              • 228<\/li>\n \n
              • 229<\/li>\n \n
              • 230<\/li>\n \n
              • 231<\/li>\n \n
              • 232<\/li>\n \n
              • 233<\/li>\n \n
              • 234<\/li>\n \n
              • 235<\/li>\n \n
              • 236<\/li>\n \n
              • 237<\/li>\n \n
              • 238<\/li>\n \n
              • 239<\/li>\n \n
              • 240<\/li>\n \n
              • 241<\/li>\n \n
              • 242<\/li>\n \n
              • 243<\/li>\n \n
              • 244<\/li>\n \n
              • 245<\/li>\n \n
              • 246<\/li>\n \n
              • 247<\/li>\n \n
              • 248<\/li>\n \n
              • 249<\/li>\n \n
              • 250<\/li>\n \n
              • 251<\/li>\n \n
              • 252<\/li>\n \n
              • 253<\/li>\n \n
              • 254<\/li>\n \n
              • 255<\/li>\n \n
              • 256<\/li>\n \n
              • 257<\/li>\n \n
              • 258<\/li>\n \n
              • 259<\/li>\n \n
              • 260<\/li>\n \n
              • 261<\/li>\n \n
              • 262<\/li>\n \n
              • 263<\/li>\n \n
              • 264<\/li>\n \n
              • 265<\/li>\n \n
              • 266<\/li>\n \n
              • 267<\/li>\n \n
              • 268<\/li>\n \n
              • 269<\/li>\n \n
              • 270<\/li>\n \n
              • 271<\/li>\n \n
              • 272<\/li>\n \n
              • 273<\/li>\n \n
              • 274<\/li>\n \n
              • 275<\/li>\n \n
              • 276<\/li>\n \n
              • 277<\/li>\n \n
              • 278<\/li>\n \n
              • 279<\/li>\n \n
              • 280<\/li>\n \n
              • 281<\/li>\n \n
              • 282<\/li>\n \n
              • 283<\/li>\n \n
              • 284<\/li>\n \n
              • 285<\/li>\n \n
              • 286<\/li>\n \n
              • 287<\/li>\n \n
              • 288<\/li>\n \n
              • 289<\/li>\n \n
              • 290<\/li>\n \n
              • 291<\/li>\n \n
              • 292<\/li>\n \n <\/ul><\/pre>\n
                package<\/span> com.netease.ad.omp.quartz.job;\n\nimport<\/span> java.lang.reflect.InvocationTargetException;\nimport<\/span> java.lang.reflect.Method;\n\nimport<\/span> com.netease.ad.omp.common.utils.SpringUtils;\nimport<\/span> com.netease.ad.omp.entity.sys.ScheduleJob;\nimport<\/span> org.apache.commons.lang3.StringUtils;\nimport<\/span> org.apache.log4j.Logger;\nimport<\/span> org.quartz.JobExecutionContext;\nimport<\/span> org.springframework.context.ApplicationContext;\n\n\/**\n * Created with IntelliJ IDEA\n * ProjectName: omp\n * Author:  bjsonghongxu\n * CreateTime : 15:58\n * Email: bjsonghongxu@crop.netease.com\n * Class Description:\n *   \u5b9a\u65f6\u4efb\u52a1\u5de5\u5177\u7c7b\n *\/<\/span>\npublic<\/span> class<\/span> JobUtils {\n    public<\/span> final<\/span> static<\/span> Logger log = Logger.getLogger(JobUtils.class<\/span>);\n    public<\/span> static<\/span> final<\/span> String STATUS_RUNNING = \"1\"<\/span>; \/\/\u542f\u52a8\u72b6\u6001<\/span>\n    public<\/span> static<\/span> final<\/span> String STATUS_NOT_RUNNING = \"0\"<\/span>; \/\/\u672a\u542f\u52a8\u72b6\u6001<\/span>\n    public<\/span> static<\/span> final<\/span> String CONCURRENT_IS = \"1\"<\/span>;\n    public<\/span> static<\/span> final<\/span> String CONCURRENT_NOT = \"0\"<\/span>;\n\n    private<\/span> ApplicationContext ctx;\n\n    \/**\n     * \u901a\u8fc7\u53cd\u5c04\u8c03\u7528scheduleJob\u4e2d\u5b9a\u4e49\u7684\u65b9\u6cd5\n     *\n     * @param scheduleJob\n     *\/<\/span>\n    public<\/span> static<\/span> void<\/span> invokMethod(ScheduleJob scheduleJob,JobExecutionContext context) {\n        Object object = null<\/span>;\n        Class<\/span> clazz = null<\/span>;\n        if<\/span> (StringUtils.isNotBlank(scheduleJob.getSpringId())) {\n            object = SpringUtils.getBean(scheduleJob.getSpringId());\n        } else<\/span> if<\/span> (StringUtils.isNotBlank(scheduleJob.getBeanClass())) {\n            try<\/span> {\n                clazz = Class<\/span>.forName(scheduleJob.getBeanClass());\n                object = clazz.newInstance();\n            } catch<\/span> (Exception e) {\n                \/\/ TODO Auto-generated catch block<\/span>\n                e.printStackTrace();\n            }\n\n        }\n        if<\/span> (object == null<\/span>) {\n            log.error(\"\u4efb\u52a1\u540d\u79f0 = [\"<\/span> + scheduleJob.getJobName() + \"]---------------\u672a\u542f\u52a8\u6210\u529f\uff0c\u8bf7\u68c0\u67e5\u662f\u5426\u914d\u7f6e\u6b63\u786e\uff01\uff01\uff01\"<\/span>);\n            return<\/span>;\n        }\n        clazz = object.getClass();\n        Method method = null<\/span>;\n        try<\/span> {\n            method = clazz.getMethod(scheduleJob.getMethodName(), new<\/span> Class<\/span>[] {JobExecutionContext.class<\/span>});\n        } catch<\/span> (NoSuchMethodException e) {\n            log.error(\"\u4efb\u52a1\u540d\u79f0 = [\"<\/span> + scheduleJob.getJobName() + \"]---------------\u672a\u542f\u52a8\u6210\u529f\uff0c\u65b9\u6cd5\u540d\u8bbe\u7f6e\u9519\u8bef\uff01\uff01\uff01\"<\/span>);\n        } catch<\/span> (SecurityException e) {\n            \/\/ TODO Auto-generated catch block<\/span>\n            e.printStackTrace();\n        }\n        if<\/span> (method != null<\/span>) {\n            try<\/span> {\n                method.invoke(object, new<\/span> Object[] {context});\n            } catch<\/span> (IllegalAccessException e) {\n                \/\/ TODO Auto-generated catch block<\/span>\n                e.printStackTrace();\n            } catch<\/span> (IllegalArgumentException e) {\n                \/\/ TODO Auto-generated catch block<\/span>\n                e.printStackTrace();\n            } catch<\/span> (InvocationTargetException e) {\n                \/\/ TODO Auto-generated catch block<\/span>\n                e.printStackTrace();\n            }\n        }\n        log.info(\"\u4efb\u52a1\u540d\u79f0 = [\"<\/span> + scheduleJob.getJobName() + \"]----------\u542f\u52a8\u6210\u529f\"<\/span>);\n    }\n}<\/pre>\n
                package<\/span> com.netease.ad.omp.quartz.job;\n\nimport<\/span> com.netease.ad.omp.entity.sys.ScheduleJob;\nimport<\/span> org.apache.log4j.Logger;\nimport<\/span> org.quartz.Job;\nimport<\/span> org.quartz.JobExecutionContext;\nimport<\/span> org.quartz.JobExecutionException;\n\n\n\/** * * @Description<\/span>: \u8ba1\u5212\u4efb\u52a1\u6267\u884c\u5904 \u65e0\u72b6\u6001 * Spring\u8c03\u5ea6\u4efb\u52a1 (\u91cd\u5199 quartz \u7684 QuartzJobBean \u7c7b\u539f\u56e0\u662f\u5728\u4f7f\u7528 quartz+spring \u628a quartz \u7684 task \u5b9e\u4f8b\u5316\u8fdb\u5165\u6570\u636e\u5e93\u65f6\uff0c\u4f1a\u4ea7\u751f\uff1a serializable \u7684\u9519\u8bef) *\/<\/span>\npublic<\/span> class<\/span> QuartzJobFactory<\/span> implements<\/span> Job<\/span> <\/span>{\n   public<\/span> final<\/span> Logger log = Logger.getLogger(this<\/span>.getClass());\n\n   @Override<\/span>\n   public<\/span> void<\/span> execute<\/span>(JobExecutionContext context)<\/span> throws<\/span> JobExecutionException <\/span>{\n      ScheduleJob scheduleJob = (ScheduleJob) context.getMergedJobDataMap().get(\"scheduleJob\"<\/span>);\n      JobUtils.invokMethod(scheduleJob,context);\n   }\n}<\/code>\n \n \n \n 
                  \n \n
                • 1<\/li>\n \n
                • 2<\/li>\n \n
                • 3<\/li>\n \n
                • 4<\/li>\n \n
                • 5<\/li>\n \n
                • 6<\/li>\n \n
                • 7<\/li>\n \n
                • 8<\/li>\n \n
                • 9<\/li>\n \n
                • 10<\/li>\n \n
                • 11<\/li>\n \n
                • 12<\/li>\n \n
                • 13<\/li>\n \n
                • 14<\/li>\n \n
                • 15<\/li>\n \n
                • 16<\/li>\n \n
                • 17<\/li>\n \n
                • 18<\/li>\n \n
                • 19<\/li>\n \n
                • 20<\/li>\n \n
                • 21<\/li>\n \n
                • 22<\/li>\n \n <\/ul><\/pre>\n
                  package<\/span> com.netease.ad.omp.quartz.job;\n\nimport<\/span> com.netease.ad.omp.entity.sys.ScheduleJob;\nimport<\/span> org.apache.log4j.Logger;\nimport<\/span> org.quartz.DisallowConcurrentExecution;\nimport<\/span> org.quartz.Job;\nimport<\/span> org.quartz.JobExecutionContext;\nimport<\/span> org.quartz.JobExecutionException;\n\n\n\/** * * @Description<\/span>: \u82e5\u4e00\u4e2a\u65b9\u6cd5\u4e00\u6b21\u6267\u884c\u4e0d\u5b8c\u4e0b\u6b21\u8f6e\u8f6c\u65f6\u5219\u7b49\u5f85\u8be5\u65b9\u6cd5\u6267\u884c\u5b8c\u540e\u624d\u6267\u884c\u4e0b\u4e00\u6b21\u64cd\u4f5c * Spring\u8c03\u5ea6\u4efb\u52a1 (\u91cd\u5199 quartz \u7684 QuartzJobBean \u7c7b\u539f\u56e0\u662f\u5728\u4f7f\u7528 quartz+spring \u628a quartz \u7684 task \u5b9e\u4f8b\u5316\u8fdb\u5165\u6570\u636e\u5e93\u65f6\uff0c\u4f1a\u4ea7\u751f\uff1a serializable \u7684\u9519\u8bef) *\/<\/span>\n@DisallowConcurrentExecution<\/span>\npublic<\/span> class<\/span> QuartzJobFactoryDisallowConcurrentExecution<\/span> implements<\/span> Job<\/span> <\/span>{\n   public<\/span> final<\/span> Logger log = Logger.getLogger(this<\/span>.getClass());\n\n   @Override<\/span>\n   public<\/span> void<\/span> execute<\/span>(JobExecutionContext context)<\/span> throws<\/span> JobExecutionException <\/span>{\n      ScheduleJob scheduleJob = (ScheduleJob) context.getMergedJobDataMap().get(\"scheduleJob\"<\/span>);\n      JobUtils.invokMethod(scheduleJob,context);\n\n   }\n}<\/code>\n \n \n \n 
                    \n \n
                  • 1<\/li>\n \n
                  • 2<\/li>\n \n
                  • 3<\/li>\n \n
                  • 4<\/li>\n \n
                  • 5<\/li>\n \n
                  • 6<\/li>\n \n
                  • 7<\/li>\n \n
                  • 8<\/li>\n \n
                  • 9<\/li>\n \n
                  • 10<\/li>\n \n
                  • 11<\/li>\n \n
                  • 12<\/li>\n \n
                  • 13<\/li>\n \n
                  • 14<\/li>\n \n
                  • 15<\/li>\n \n
                  • 16<\/li>\n \n
                  • 17<\/li>\n \n
                  • 18<\/li>\n \n
                  • 19<\/li>\n \n
                  • 20<\/li>\n \n
                  • 21<\/li>\n \n
                  • 22<\/li>\n \n
                  • 23<\/li>\n \n
                  • 24<\/li>\n \n
                  • 25<\/li>\n \n <\/ul><\/pre>\n

                     <\/p>\n

                    package com.netease.ad.omp.entity.sys;\n\nimport<\/span> javax.persistence.Id;\nimport<\/span> javax.persistence.Table;\nimport<\/span> java.io.Serializable;\nimport<\/span> java.util.Date;\n\n\/**\n * Created with IntelliJ IDEA\n * ProjectName: omp\n * Author:  bjsonghongxu\n * CreateTime : 15:48\n * Email: bjsonghongxu@crop.netease.com\n * Class Description:\n *   \u8ba1\u5212\u4efb\u52a1\u4fe1\u606f\n *\/<\/span>\n@Table(name = \"task_schedule_job\"<\/span>)\npublic<\/span> class<\/span> ScheduleJob implements<\/span> Serializable {\n    @Id\n    private<\/span> Long jobId;\n\n    private<\/span> Date<\/span> createTime;\n\n    private<\/span> Date<\/span> updateTime;\n    \/**\n     * \u4efb\u52a1\u540d\u79f0\n     *\/<\/span>\n    private<\/span> String<\/span> jobName;\n    \/**\n     * \u4efb\u52a1\u5206\u7ec4\n     *\/<\/span>\n    private<\/span> String<\/span> jobGroup;\n    \/**\n     * \u4efb\u52a1\u72b6\u6001 \u662f\u5426\u542f\u52a8\u4efb\u52a1\n     *\/<\/span>\n    private<\/span> String<\/span> jobStatus;\n    \/**\n     * cron\u8868\u8fbe\u5f0f\n     *\/<\/span>\n    private<\/span> String<\/span> cronExpression;\n    \/**\n     * \u63cf\u8ff0\n     *\/<\/span>\n    private<\/span> String<\/span> description;\n    \/**\n     * \u4efb\u52a1\u6267\u884c\u65f6\u8c03\u7528\u54ea\u4e2a\u7c7b\u7684\u65b9\u6cd5 \u5305\u540d+\u7c7b\u540d\n     *\/<\/span>\n    private<\/span> String<\/span> beanClass;\n    \/**\n     * \u4efb\u52a1\u662f\u5426\u6709\u72b6\u6001\n     *\/<\/span>\n    private<\/span> String<\/span> isConcurrent;\n    \/**\n     * spring bean\n     *\/<\/span>\n    private<\/span> String<\/span> springId;\n    \/**\n     * \u4efb\u52a1\u8c03\u7528\u7684\u65b9\u6cd5\u540d\n     *\/<\/span>\n    private<\/span> String<\/span> methodName;\n\n    public<\/span> Long getJobId() {\n        return<\/span> jobId;\n    }\n\n    public<\/span> void<\/span> setJobId(Long jobId) {\n        this<\/span>.jobId = jobId;\n    }\n\n    public<\/span> Date<\/span> getCreateTime() {\n        return<\/span> createTime;\n    }\n\n    public<\/span> void<\/span> setCreateTime(Date<\/span> createTime) {\n        this<\/span>.createTime = createTime;\n    }\n\n    public<\/span> Date<\/span> getUpdateTime() {\n        return<\/span> updateTime;\n    }\n\n    public<\/span> void<\/span> setUpdateTime(Date<\/span> updateTime) {\n        this<\/span>.updateTime = updateTime;\n    }\n\n    public<\/span> String<\/span> getJobName() {\n        return<\/span> jobName;\n    }\n\n    public<\/span> void<\/span> setJobName(String<\/span> jobName) {\n        this<\/span>.jobName = jobName;\n    }\n\n    public<\/span> String<\/span> getJobGroup() {\n        return<\/span> jobGroup;\n    }\n\n    public<\/span> void<\/span> setJobGroup(String<\/span> jobGroup) {\n        this<\/span>.jobGroup = jobGroup;\n    }\n\n    public<\/span> String<\/span> getJobStatus() {\n        return<\/span> jobStatus;\n    }\n\n    public<\/span> void<\/span> setJobStatus(String<\/span> jobStatus) {\n        this<\/span>.jobStatus = jobStatus;\n    }\n\n    public<\/span> String<\/span> getCronExpression() {\n        return<\/span> cronExpression;\n    }\n\n    public<\/span> void<\/span> setCronExpression(String<\/span> cronExpression) {\n        this<\/span>.cronExpression = cronExpression;\n    }\n\n    public<\/span> String<\/span> getDescription() {\n        return<\/span> description;\n    }\n\n    public<\/span> void<\/span> setDescription(String<\/span> description) {\n        this<\/span>.description = description;\n    }\n\n    public<\/span> String<\/span> getBeanClass() {\n        return<\/span> beanClass;\n    }\n\n    public<\/span> void<\/span> setBeanClass(String<\/span> beanClass) {\n        this<\/span>.beanClass = beanClass;\n    }\n\n    public<\/span> String<\/span> getIsConcurrent() {\n        return<\/span> isConcurrent;\n    }\n\n    public<\/span> void<\/span> setIsConcurrent(String<\/span> isConcurrent) {\n        this<\/span>.isConcurrent = isConcurrent;\n    }\n\n    public<\/span> String<\/span> getSpringId() {\n        return<\/span> springId;\n    }\n\n    public<\/span> void<\/span> setSpringId(String<\/span> springId) {\n        this<\/span>.springId = springId;\n    }\n\n    public<\/span> String<\/span> getMethodName() {\n        return<\/span> methodName;\n    }\n\n    public<\/span> void<\/span> setMethodName(String<\/span> methodName) {\n        this<\/span>.methodName = methodName;\n    }\n}<\/pre>\n
                    package<\/span> com.netease.ad.omp.common.utils;\n\nimport<\/span> org.springframework.beans.BeansException;\nimport<\/span> org.springframework.beans.factory.NoSuchBeanDefinitionException;\nimport<\/span> org.springframework.beans.factory.config.BeanFactoryPostProcessor;\nimport<\/span> org.springframework.beans.factory.config.ConfigurableListableBeanFactory;\n\npublic<\/span> final<\/span> class<\/span> SpringUtils<\/span> implements<\/span> BeanFactoryPostProcessor<\/span> <\/span>{\n\n   private<\/span> static<\/span> ConfigurableListableBeanFactory beanFactory; \/\/ Spring\u5e94\u7528\u4e0a\u4e0b\u6587\u73af\u5883<\/span>\n\n   @Override<\/span>\n   public<\/span> void<\/span> postProcessBeanFactory<\/span>(ConfigurableListableBeanFactory beanFactory)<\/span> throws<\/span> BeansException <\/span>{\n      SpringUtils.beanFactory = beanFactory;\n   }\n\n   \/** * \u83b7\u53d6\u5bf9\u8c61 * * @param<\/span> name * @return<\/span> Object \u4e00\u4e2a\u4ee5\u6240\u7ed9\u540d\u5b57\u6ce8\u518c\u7684bean\u7684\u5b9e\u4f8b * @throws<\/span> BeansException * *\/<\/span>\n   @SuppressWarnings<\/span>(\"unchecked\"<\/span>)\n   public<\/span> static<\/span> <T> T getBean<\/span>(String name)<\/span> throws<\/span> BeansException <\/span>{\n      return<\/span> (T) beanFactory.getBean(name);\n   }\n\n   \/** * \u83b7\u53d6\u7c7b\u578b\u4e3arequiredType\u7684\u5bf9\u8c61 * * @param<\/span> clz * @return<\/span> * @throws<\/span> BeansException * *\/<\/span>\n   public<\/span> static<\/span> <T> T getBean<\/span>(Class<T> clz)<\/span> throws<\/span> BeansException <\/span>{\n      @SuppressWarnings<\/span>(\"unchecked\"<\/span>)\n      T result = (T) beanFactory.getBean(clz);\n      return<\/span> result;\n   }\n\n   \/** * \u5982\u679cBeanFactory\u5305\u542b\u4e00\u4e2a\u4e0e\u6240\u7ed9\u540d\u79f0\u5339\u914d\u7684bean\u5b9a\u4e49\uff0c\u5219\u8fd4\u56detrue * * @param<\/span> name * @return<\/span> boolean *\/<\/span>\n   public<\/span> static<\/span> boolean<\/span> containsBean<\/span>(String name)<\/span> <\/span>{\n      return<\/span> beanFactory.containsBean(name);\n   }\n\n   \/** * \u5224\u65ad\u4ee5\u7ed9\u5b9a\u540d\u5b57\u6ce8\u518c\u7684bean\u5b9a\u4e49\u662f\u4e00\u4e2asingleton\u8fd8\u662f\u4e00\u4e2aprototype\u3002 * \u5982\u679c\u4e0e\u7ed9\u5b9a\u540d\u5b57\u76f8\u5e94\u7684bean\u5b9a\u4e49\u6ca1\u6709\u88ab\u627e\u5230\uff0c\u5c06\u4f1a\u629b\u51fa\u4e00\u4e2a\u5f02\u5e38\uff08NoSuchBeanDefinitionException\uff09 * * @param<\/span> name * @return<\/span> boolean * @throws<\/span> NoSuchBeanDefinitionException * *\/<\/span>\n   public<\/span> static<\/span> boolean<\/span> isSingleton<\/span>(String name)<\/span> throws<\/span> NoSuchBeanDefinitionException <\/span>{\n      return<\/span> beanFactory.isSingleton(name);\n   }\n\n   \/** * @param<\/span> name * @return<\/span> Class \u6ce8\u518c\u5bf9\u8c61\u7684\u7c7b\u578b * @throws<\/span> NoSuchBeanDefinitionException * *\/<\/span>\n   public<\/span> static<\/span> Class<?> getType(String name) throws<\/span> NoSuchBeanDefinitionException {\n      return<\/span> beanFactory.getType(name);\n   }\n\n   \/** * \u5982\u679c\u7ed9\u5b9a\u7684bean\u540d\u5b57\u5728bean\u5b9a\u4e49\u4e2d\u6709\u522b\u540d\uff0c\u5219\u8fd4\u56de\u8fd9\u4e9b\u522b\u540d * * @param<\/span> name * @return<\/span> * @throws<\/span> NoSuchBeanDefinitionException * *\/<\/span>\n   public<\/span> static<\/span> String[] getAliases(String name) throws<\/span> NoSuchBeanDefinitionException {\n      return<\/span> beanFactory.getAliases(name);\n   }\n\n}<\/code>\n \n \n \n 
                      \n \n
                    • 1<\/li>\n \n
                    • 2<\/li>\n \n
                    • 3<\/li>\n \n
                    • 4<\/li>\n \n
                    • 5<\/li>\n \n
                    • 6<\/li>\n \n
                    • 7<\/li>\n \n
                    • 8<\/li>\n \n
                    • 9<\/li>\n \n
                    • 10<\/li>\n \n
                    • 11<\/li>\n \n
                    • 12<\/li>\n \n
                    • 13<\/li>\n \n
                    • 14<\/li>\n \n
                    • 15<\/li>\n \n
                    • 16<\/li>\n \n
                    • 17<\/li>\n \n
                    • 18<\/li>\n \n
                    • 19<\/li>\n \n
                    • 20<\/li>\n \n
                    • 21<\/li>\n \n
                    • 22<\/li>\n \n
                    • 23<\/li>\n \n
                    • 24<\/li>\n \n
                    • 25<\/li>\n \n
                    • 26<\/li>\n \n
                    • 27<\/li>\n \n
                    • 28<\/li>\n \n
                    • 29<\/li>\n \n
                    • 30<\/li>\n \n
                    • 31<\/li>\n \n
                    • 32<\/li>\n \n
                    • 33<\/li>\n \n
                    • 34<\/li>\n \n
                    • 35<\/li>\n \n
                    • 36<\/li>\n \n
                    • 37<\/li>\n \n
                    • 38<\/li>\n \n
                    • 39<\/li>\n \n
                    • 40<\/li>\n \n
                    • 41<\/li>\n \n
                    • 42<\/li>\n \n
                    • 43<\/li>\n \n
                    • 44<\/li>\n \n
                    • 45<\/li>\n \n
                    • 46<\/li>\n \n
                    • 47<\/li>\n \n
                    • 48<\/li>\n \n
                    • 49<\/li>\n \n
                    • 50<\/li>\n \n
                    • 51<\/li>\n \n
                    • 52<\/li>\n \n
                    • 53<\/li>\n \n
                    • 54<\/li>\n \n
                    • 55<\/li>\n \n
                    • 56<\/li>\n \n
                    • 57<\/li>\n \n
                    • 58<\/li>\n \n
                    • 59<\/li>\n \n
                    • 60<\/li>\n \n
                    • 61<\/li>\n \n
                    • 62<\/li>\n \n
                    • 63<\/li>\n \n
                    • 64<\/li>\n \n
                    • 65<\/li>\n \n
                    • 66<\/li>\n \n
                    • 67<\/li>\n \n
                    • 68<\/li>\n \n
                    • 69<\/li>\n \n
                    • 70<\/li>\n \n
                    • 71<\/li>\n \n
                    • 72<\/li>\n \n
                    • 73<\/li>\n \n
                    • 74<\/li>\n \n
                    • 75<\/li>\n \n
                    • 76<\/li>\n \n
                    • 77<\/li>\n \n
                    • 78<\/li>\n \n
                    • 79<\/li>\n \n
                    • 80<\/li>\n \n
                    • 81<\/li>\n \n
                    • 82<\/li>\n \n
                    • 83<\/li>\n \n
                    • 84<\/li>\n \n
                    • 85<\/li>\n \n
                    • 86<\/li>\n \n
                    • 87<\/li>\n \n
                    • 88<\/li>\n \n <\/ul><\/pre>\n

                       <\/p>\n

                      \u81f3\u4e8e\u524d\u7aef\u81ea\u5df1\u753b\u4e2a\u7b80\u5355\u7684\u754c\u9762\u5373\u53ef\u4f7f\u7528\u4e86\u3002<\/p>\n

                      <\/span><\/p>\n

                      \u56db\u3001\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6848<\/h2>\n

                      <\/span><\/p>\n

                          4.1quartz mysql \u6b7b\u9501\u95ee\u9898<\/h3>\n

                            quartz\u6587\u6863\u63d0\u5230\uff0c\u5982\u679c\u5728\u96c6\u7fa4\u73af\u5883\u4e0b\uff0c\u6700\u597d\u5c06\u914d\u7f6e\u9879org.quartz.jobStore.txIsolationLevelSerializable\u8bbe\u7f6e\u4e3atrue<\/p>\n

                      \u95ee\u9898\uff1a<\/p>\n

                      \u8fd9\u4e2a\u9009\u9879\u5728mysql\u4e0b\u4f1a\u975e\u5e38\u5bb9\u6613\u51fa\u73b0\u6b7b\u9501\u95ee\u9898\u3002<\/p>\n

                      2014-12-29 09:55:28.006 [QuartzScheduler_clusterQuartzSchedular-BJ-YQ-64.2491419487774923_ClusterManager] ERROR o.q.impl.jdbcjobstore.JobStoreTX [U][] - ClusterManager: Error managing cluster: Failure updating scheduler state when checking-in: Deadlock found when trying to get lock; try restarting transaction<\/p>\n

                      \u8fd9\u4e2a\u9009\u9879\u5b58\u5728\u610f\u4e49\uff1a<\/p>\n

                      quartz\u9700\u8981\u63d0\u5347\u9694\u79bb\u7ea7\u522b\u6765\u4fdd\u969c\u81ea\u5df1\u7684\u8fd0\u4f5c\uff0c\u4e0d\u8fc7\uff0c\u7531\u4e8e\u5404\u6570\u636e\u5e93\u5b9e\u73b0\u7684\u9694\u79bb\u7ea7\u522b\u5b9a\u4e49\u90fd\u4e0d\u4e00\u6837\uff0c\u6240\u4ee5quartz\u63d0\u4f9b\u4e00\u4e2a\u8bbe\u7f6e\u5e8f\u5217\u5316\u8fd9\u6837\u7684\u9694\u79bb\u7ea7\u522b\u5b58\u5728\uff0c\u56e0\u4e3a\u4f8b\u5982oracle\u4e2d\u662f\u6ca1\u6709\u672a\u63d0\u4ea4\u8bfb\u548c\u53ef\u91cd\u590d\u8bfb\u8fd9\u6837\u7684\u9694\u79bb\u7ea7\u522b\u5b58\u5728\u3002\u4f46\u662f\u7531\u4e8emysql\u9ed8\u8ba4\u7684\u662f\u53ef\u91cd\u590d\u8bfb\uff0c\u6bd4\u63d0\u4ea4\u8bfb\u9ad8\u4e86\u4e00\u4e2a\u7ea7\u522b\uff0c\u6240\u4ee5\u5df2\u7ecf\u53ef\u4ee5\u6ee1\u8db3quartz\u96c6\u7fa4\u7684\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n

                      <\/span><\/p>\n

                      \u4e94\u3001\u76f8\u5173\u77e5\u8bc6<\/h2>\n

                      <\/span><\/p>\n

                       5.1\u3001QuartzSchedulerThread\u7ebf\u7a0b<\/h3>\n

                      \u7ebf\u7a0b\u7684\u4e3b\u8981\u903b\u8f91\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n
                      \n
                      1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16<\/pre>\n<\/td>\n
                      \n
                      while<\/span> (!halted.get<\/span>()) {\n  int<\/span> availThreadCount = qsRsrcs.getThreadPool().blockForAvailableThreads();\n  triggers = qsRsrcs.getJobStore().acquireNextTriggers(now + idleWaitTime, Math.min(availThreadCount, qsRsrcs.getMaxBatchSize()),qsRsrcs.getBatchTimeWindow());\n  long<\/span> triggerTime = triggers.get<\/span>(0<\/span>).getNextFireTime().getTime();\n  long<\/span> timeUntilTrigger = triggerTime - now;\n  while<\/span>(timeUntilTrigger > 2<\/span>) {\n    now = System.currentTimeMillis();\n    timeUntilTrigger = triggerTime - now;\n  }\n  List<TriggerFiredResult> bndle = qsRsrcs.getJobStore().triggersFired(triggers);\n  for<\/span>(int<\/span> i = 0<\/span>;i < res.size();i++){\n    JobRunShell shell = qsRsrcs.getJobRunShellFactory().createJobRunShell(bndle);\n    shell.initialize(qs);\n    qsRsrcs.getThreadPool().runInThread(shell);\n  }\n}<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
                        \n
                      1. \u5148\u83b7\u53d6\u7ebf\u7a0b\u6c60\u4e2d\u7684\u53ef\u7528\u7ebf\u7a0b\u6570\u91cf\uff08\u82e5\u6ca1\u6709\u53ef\u7528\u7684\u4f1a\u963b\u585e\uff0c\u76f4\u5230\u6709\u53ef\u7528\u7684\uff09\uff1b<\/li>\n
                      2. \u83b7\u53d630m\u5185\u8981\u6267\u884c\u7684trigger(\u5373acquireNextTriggers)\uff1a
                        \u83b7\u53d6trigger\u7684\u9501\uff0c\u901a\u8fc7select \u2026for update<\/strong>\u65b9\u5f0f\u5b9e\u73b0\uff1b\u83b7\u53d630m\u5185\uff08\u53ef\u914d\u7f6e\uff09\u8981\u6267\u884c\u7684triggers\uff08\u9700\u8981\u4fdd\u8bc1\u96c6\u7fa4\u8282\u70b9\u7684\u65f6\u95f4\u4e00\u81f4<\/strong>\uff09\uff0c\u82e5@ConcurrentExectionDisallowed<\/strong>\u4e14\u5217\u8868\u5b58\u5728\u8be5\u6761trigger\u5219\u8df3\u8fc7\uff0c\u5426\u5219\u66f4\u65b0trigger\u72b6\u6001\u4e3aACQUIRED(\u521a\u5f00\u59cb\u4e3aWAITING)\uff1b\u63d2\u5165firedTrigger\u8868\uff0c\u72b6\u6001\u4e3aACQUIRED;\uff08\u6ce8\u610f\uff1a\u5728RAMJobStore\u4e2d\uff0c\u6709\u4e2atimeTriggers\uff0c\u6392\u5e8f\u65b9\u5f0f\u662f\u6309\u89e6\u53d1\u65f6\u95f4nextFireTime\u6392\u7684\uff1bJobStoreSupport\u4ece\u6570\u636e\u5e93\u53d6\u51fatriggers\u65f6\u662f\u6309\u7167nextFireTime\u6392\u5e8f\uff09;<\/li>\n
                      3. \u7b49\u5f85\u76f4\u5230\u83b7\u53d6\u7684trigger\u4e2d\u6700\u5148\u6267\u884c\u7684trigger\u57282ms\u5185\uff1b<\/li>\n
                      4. triggersFired\uff1a
                        1\uff09\u66f4\u65b0firedTrigger\u7684status=EXECUTING;
                        2\uff09\u66f4\u65b0trigger\u4e0b\u4e00\u6b21\u89e6\u53d1\u7684\u65f6\u95f4\uff1b
                        3\uff09\u66f4\u65b0trigger\u7684\u72b6\u6001\uff1a\u65e0\u72b6\u6001\u7684trigger->WAITING\uff0c\u6709\u72b6\u6001\u7684trigger->BLOCKED\uff0c\u82e5nextFireTime==null ->COMPLETE\uff1b
                        4\uff09 commit connection,\u91ca\u653e\u9501\uff1b<\/li>\n
                      5. \u9488\u5bf9\u6bcf\u4e2a\u8981\u6267\u884c\u7684trigger\uff0c\u521b\u5efaJobRunShell\uff0c\u5e76\u653e\u5165\u7ebf\u7a0b\u6c60\u6267\u884c\uff1a
                        1\uff09execute:\u6267\u884cjob
                        2\uff09\u83b7\u53d6TRIGGER_ACCESS\u9501
                        3\uff09\u82e5\u662f\u6709\u72b6\u6001\u7684job\uff1a\u66f4\u65b0trigger\u72b6\u6001\uff1aBLOCKED->WAITING,PAUSED_BLOCKED->BLOCKED
                        4\uff09\u82e5@PersistJobDataAfterExecution\uff0c\u5219updateJobData
                        5\uff09\u5220\u9664firedTrigger
                        6\uff09commit connection\uff0c\u91ca\u653e\u9501<\/li>\n<\/ol>\n

                        \u7ebf\u7a0b\u6267\u884c\u6d41\u7a0b\u5982\u4e0b\u56fe\u6240\u793a\uff1a
                        QuartzSchedulerThread\u65f6\u5e8f\u56fe<\/p>\n

                        \u4efb\u52a1\u8c03\u5ea6\u6267\u884c\u8fc7\u7a0b\u4e2d\uff0ctrigger\u7684\u72b6\u6001\u53d8\u5316\u5982\u4e0b\u56fe\u6240\u793a\uff1a
                        \u8be5\u56fe\u6765\u81ea\u53c2\u8003\u6587\u732e5<\/p>\n

                        <\/span><\/p>\n

                        5.2.misfireHandler\u7ebf\u7a0b<\/h5>\n

                        \u4e0b\u9762\u8fd9\u4e9b\u539f\u56e0\u53ef\u80fd\u9020\u6210 misfired job:<\/p>\n

                          \n
                        1. \u7cfb\u7edf\u56e0\u4e3a\u67d0\u4e9b\u539f\u56e0\u88ab\u91cd\u542f\u3002\u5728\u7cfb\u7edf\u5173\u95ed\u5230\u91cd\u65b0\u542f\u52a8\u4e4b\u95f4\u7684\u4e00\u6bb5\u65f6\u95f4\u91cc\uff0c\u53ef\u80fd\u6709\u4e9b\u4efb\u52a1\u4f1a\u88ab misfire\uff1b<\/li>\n
                        2. Trigger \u88ab\u6682\u505c\uff08suspend\uff09\u7684\u4e00\u6bb5\u65f6\u95f4\u91cc\uff0c\u6709\u4e9b\u4efb\u52a1\u53ef\u80fd\u4f1a\u88ab misfire\uff1b<\/li>\n
                        3. \u7ebf\u7a0b\u6c60\u4e2d\u6240\u6709\u7ebf\u7a0b\u90fd\u88ab\u5360\u7528\uff0c\u5bfc\u81f4\u4efb\u52a1\u65e0\u6cd5\u88ab\u89e6\u53d1\u6267\u884c\uff0c\u9020\u6210 misfire\uff1b<\/li>\n
                        4. \u6709\u72b6\u6001\u4efb\u52a1\u5728\u4e0b\u6b21\u89e6\u53d1\u65f6\u95f4\u5230\u8fbe\u65f6\uff0c\u4e0a\u6b21\u6267\u884c\u8fd8\u6ca1\u6709\u7ed3\u675f\uff1b\u4e3a\u4e86\u5904\u7406 misfired job\uff0cQuartz \u4e2d\u4e3a trigger \u5b9a\u4e49\u4e86\u5904\u7406\u7b56\u7565\uff0c\u4e3b\u8981\u6709\u4e0b\u9762\u4e24\u79cd\uff1aMISFIRE_INSTRUCTION_FIRE_ONCE_NOW\uff1a\u9488\u5bf9 misfired job \u9a6c\u4e0a\u6267\u884c\u4e00\u6b21\uff1bMISFIRE_INSTRUCTION_DO_NOTHING\uff1a\u5ffd\u7565 misfired job\uff0c\u7b49\u5f85\u4e0b\u6b21\u89e6\u53d1\uff1b\u9ed8\u8ba4\u662fMISFIRE_INSTRUCTION_SMART_POLICY\uff0c\u8be5\u7b56\u7565\u5728CronTrigger\u4e2d=MISFIRE_INSTRUCTION_FIRE_ONCE_NOW\u7ebf\u7a0b\u9ed8\u8ba41\u5206\u949f\u6267\u884c\u4e00\u6b21\uff1b\u5728\u4e00\u4e2a\u4e8b\u52a1\u4e2d\uff0c\u9ed8\u8ba4\u4e00\u6b21\u6700\u591arecovery 20\u4e2a\uff1b<\/li>\n<\/ol>\n

                          \u6267\u884c\u6d41\u7a0b\uff1a<\/p>\n

                            \n
                          1. \u82e5\u914d\u7f6e(\u9ed8\u8ba4\u4e3atrue\uff0c\u53ef\u914d\u7f6e)\u6210\u83b7\u53d6\u9501\u524d\u5148\u68c0\u67e5\u662f\u5426\u6709\u9700\u8981recovery\u7684trigger\uff0c\u5148\u83b7\u53d6misfireCount\uff1b<\/li>\n
                          2. \u83b7\u53d6TRIGGER_ACCESS\u9501\uff1b<\/li>\n
                          3. hasMisfiredTriggersInState\uff1a\u83b7\u53d6misfired\u7684trigger\uff0c\u9ed8\u8ba4\u4e00\u4e2a\u4e8b\u52a1\u91cc\u53ea\u80fd\u6700\u592720\u4e2amisfired trigger\uff08\u53ef\u914d\u7f6e\uff09\uff0cmisfired\u5224\u65ad\u4f9d\u636e\uff1astatus=waiting,next_fire_time < current_time-misfirethreshold(\u53ef\u914d\u7f6e\uff0c\u9ed8\u8ba41min)<\/li>\n
                          4. notifyTriggerListenersMisfired<\/li>\n
                          5. updateAfterMisfire:\u83b7\u53d6misfire\u7b56\u7565(\u9ed8\u8ba4\u662fMISFIRE_INSTRUCTION_SMART_POLICY\uff0c\u8be5\u7b56\u7565\u5728CronTrigger\u4e2d=MISFIRE_INSTRUCTION_FIRE_ONCE_NOW)\uff0c\u6839\u636e\u7b56\u7565\u66f4\u65b0nextFireTime\uff1b<\/li>\n
                          6. \u5c06nextFireTime\u7b49\u66f4\u65b0\u5230trigger\u8868\uff1b<\/li>\n
                          7. commit connection\uff0c\u91ca\u653e\u95018.\u5982\u679c\u8fd8\u6709\u66f4\u591a\u7684misfired\uff0csleep\u77ed\u6682\u65f6\u95f4(\u4e3a\u4e86\u96c6\u7fa4\u8d1f\u8f7d\u5747\u8861)\uff0c\u5426\u5219sleep misfirethreshold\u65f6\u95f4\uff0c\u540e\u7ee7\u7eed\u8f6e\u8be2\uff1b<\/li>\n<\/ol>\n

                            misfireHandler\u7ebf\u7a0b\u6267\u884c\u6d41\u7a0b\u5982\u4e0b\u56fe\u6240\u793a\uff1a
                            misfireHandler\u7ebf\u7a0b\u65f6\u5e8f\u56fe<\/p>\n

                            <\/span><\/p>\n

                            5.3.clusterManager\u7ebf\u7a0b<\/h5>\n

                            \u521d\u59cb\u5316\uff1a
                            failedInstance=failed+self+firedTrigger\u8868\u4e2d\u7684schedulerName\u5728scheduler_state\u8868\u4e2d\u627e\u4e0d\u5230\u7684\uff08\u5b64\u513f\uff09<\/p>\n

                            \u7ebf\u7a0b\u6267\u884c\uff1a
                            \u6bcf\u4e2a\u670d\u52a1\u5668\u4f1a\u5b9a\u65f6(org.quartz.jobStore.clusterCheckinInterval<\/strong>\u8fd9\u4e2a\u65f6\u95f4)\u66f4\u65b0SCHEDULER_STATE\u8868\u7684LAST_CHECKIN_TIME\uff0c\u82e5\u8fd9\u4e2a\u5b57\u6bb5\u8fdc\u8fdc\u8d85\u51fa\u4e86\u8be5\u66f4\u65b0\u7684\u65f6\u95f4\uff0c\u5219\u8ba4\u4e3a\u8be5\u670d\u52a1\u5668\u5b9e\u4f8b\u6302\u4e86\uff1b
                            \u6ce8\u610f\uff1a\u6bcf\u4e2a\u670d\u52a1\u5668\u5b9e\u4f8b\u6709\u552f\u4e00\u7684id\uff0c\u82e5\u914d\u7f6e\u4e3aAUTO<\/strong>\uff0c\u5219\u4e3ahostname+current_time<\/p>\n

                            \u7ebf\u7a0b\u6267\u884c\u7684\u5177\u4f53\u6d41\u7a0b\uff1a<\/p>\n

                              \n
                            1. \u68c0\u67e5\u662f\u5426\u6709\u8d85\u65f6\u7684\u5b9e\u4f8bfailedInstances;<\/li>\n
                            2. \u66f4\u65b0\u8be5\u670d\u52a1\u5668\u5b9e\u4f8b\u7684LAST_CHECKIN_TIME\uff1b
                              \u82e5\u6709\u8d85\u65f6\u7684\u5b9e\u4f8b\uff1a<\/li>\n
                            3. \u83b7\u53d6STATE_ACCESS\u9501\uff1b<\/li>\n
                            4. \u83b7\u53d6\u8d85\u65f6\u7684\u5b9e\u4f8bfailedInstances;<\/li>\n
                            5. \u83b7\u53d6TRIGGER_ACCESS\u9501\uff1b<\/li>\n
                            6. clusterRecover:<\/li>\n<\/ol>\n
                                \n
                              • \u9488\u5bf9\u6bcf\u4e2afailedInstances\uff0c\u901a\u8fc7instanceId\u83b7\u53d6\u6bcf\u4e2a\u5b9e\u4f8b\u7684firedTriggers;<\/li>\n
                              • \u9488\u5bf9\u6bcf\u4e2afiredTrigger\uff1a
                                1) \u66f4\u65b0trigger\u72b6\u6001\uff1a
                                BLOCKED->WAITING
                                PAUSED_BLOCKED->PAUSED
                                ACQUIRED->WAITING
                                2) \u82e5firedTrigger\u4e0d\u662fACQUIRED\u72b6\u6001\uff08\u5728\u6267\u884c\u72b6\u6001\uff09,\u4e14jobRequestRecovery<\/strong>=true:
                                \u521b\u5efa\u4e00\u4e2aSimpleTrigger\uff0c\u5b58\u50a8\u5230trigger\u8868\uff0cstatus=waiting,MISFIRE_INSTR=MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY.
                                3) \u5220\u9664firedTrigger<\/li>\n<\/ul>\n

                                clusterManager\u7ebf\u7a0b\u6267\u884c\u65f6\u5e8f\u56fe\u5982\u4e0b\u56fe\u6240\u793a\uff1a <\/p>\n

                                <\/span><\/p>\n

                                5.4\u6e90\u7801\u5206\u6790\u9501<\/h3>\n

                                \u76ee\u524d\u4ee3\u7801\u4e2d\u884c\u9501\u53ea\u7528\u5230\u4e86STATE_ACCESS \u548cTRIGGER_ACCESS \u8fd9\u4e24\u79cd\u3002
                                 <\/p>\n

                                1\u3001TRIGGER_ACCESS
                                \u5148\u4e86\u89e3\u4e00\u7bc7\u6587\u7ae0\uff0c\u901a\u8fc7\u6e90\u7801\u6765\u5206\u6790quartz\u662f\u5982\u4f55\u901a\u8fc7\u52a0\u9501\u6765\u5b9e\u73b0\u96c6\u7fa4\u73af\u5883\uff0c\u89e6\u53d1\u5668\u72b6\u6001\u7684\u4e00\u81f4\u6027\u3002 
                                http:\/\/www.360doc.com\/content\/14\/0926\/08\/15077656_412418636.shtml
                                \u53ef\u4ee5\u770b\u5230\u89e6\u53d1\u5668\u7684\u64cd\u4f5c\u4e3b\u8981\u7528\u4e3b\u7ebf\u7a0bStdScheduleThread\u6765\u5b8c\u6210\uff0c\u4e0d\u7ba1\u662f\u83b7\u53d6\u9700\u8981\u89e6\u53d1\u768430S\u5185\u7684\u89e6\u53d1\u5668\uff0c\u8fd8\u662f\u89e6\u53d1\u8fc7\u7a0b\u3002select\u548cupdate\u89e6\u53d1\u5668\u8868\u65f6
                                \u90fd\u4f1a\u5148\u52a0\u9501\uff0c\u540e\u89e3\u9501\u3002\u5982\u679c\u6570\u636e\u5e93\u8d44\u6e90\u7ade\u4e89\u6bd4\u8f83\u5927\u7684\u8bdd\uff0c\u9501\u4f1a\u5f71\u54cd\u6574\u4e2a\u6027\u80fd\u3002\u53ef\u4ee5\u8003\u8651\u5c06\u4efb\u52a1\u4fe1\u606f\u653e\u5728\u5206\u5e03\u5f0f\u5185\u5b58\uff0c\u5982redis\u4e0a\u8fdb\u884c\u5904\u7406\u3002\u6570\u636e\u5e93\u53ea\u662f\u5b9a\u65f6\u4eceredis\u4e0aload\u6570\u636e\u4e0b\u6765\u505a\u7edf\u8ba1\u3002<\/p>\n

                                \u5b9e\u73b0\u90fd\u5728JobStoreSupport\u7c7b <\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
                                \u52a0\u9501\u7c7b\u578b<\/td>\n\u52a0\u9501\u65b9\u6cd5<\/td>\n\u5e95\u5c42\u6570\u636e\u5e93\u64cd\u4f5c<\/td>\n\u5907\u6ce8<\/td>\n<\/tr>\n
                                executeInNonManagedTXLock<\/td>\nacquireNextTrigger<\/td>\nselectTriggerToAcquire
                                selectTrigger
                                selectJobDetail
                                insertFiredTrigger<\/td>\n
                                \u67e5\u8be2\u9700\u8981\u70b9\u706b\u7684trigger
                                \u9009\u62e9\u9700\u8981\u6267\u884c\u7684trigger\u52a0\u5165\u5230fired_trigger\u8868<\/td>\n<\/tr>\n
                                for\u6267\u884c triggerFired<\/td>\nselectJobDetail
                                selectCalendar
                                updateFiredTrigger
                                triggerExists updateTrigger<\/td>\n
                                \u70b9\u706btrigger
                                \u4fee\u6539trigger\u72b6\u6001\u4e3a\u53ef\u6267\u884c\u72b6\u6001\u3002<\/td>\n<\/tr>\n
                                recoverJobs<\/td>\nupdateTriggerStatesFromOtherStates
                                hasMisfiredTriggersInState doUpdateOfMisfiredTrigger
                                selectTriggersForRecoveringJobs
                                selectTriggersInState
                                deleteFiredTriggers<\/td>\n
                                \u975e\u96c6\u7fa4\u73af\u5883\u4e0b\u91cd\u65b0\u6267\u884c
                                failed\u4e0emisfired\u7684trigger<\/td>\n<\/tr>\n
                                retryExecuteInNonManagedTXLock<\/td>\nreleaseAcquiredTrigger<\/td>\nupdateTriggerStateFromOtherState
                                deleteFiredTrigger<\/td>\n
                                \u5f02\u5e38\u60c5\u51b5\u4e0b\u91cd\u65b0\u91ca\u653etrigger\u5230\u521d\u4f7f\u72b6\u6001\u3002<\/td>\n<\/tr>\n
                                triggeredJobComplete<\/td>\nselectTriggerStatus
                                removeTrigger   updateTriggerState
                                deleteFiredTrigger<\/td>\n
                                \u89e6\u53d1JOB\u4efb\u52a1\u5b8c\u6210\u540e\u7684\u5904\u7406\u3002<\/td>\n<\/tr>\n
                                obtainLock<\/td>\nrecoverMisfiredJobs<\/td>\nhasMisfiredTriggersInState doUpdateOfMisfiredTrigger<\/td>\n\u91cd\u65b0\u6267\u884cmisfired\u7684trigger
                                \u53ef\u4ee5\u5728\u542f\u52a8\u65f6\u6267\u884c\uff0c\u4e5f\u53ef\u4ee5\u7531misfired\u7ebf\u7a0b\u5b9a\u671f\u6267\u884c\u3002<\/td>\n<\/tr>\n
                                clusterRecover<\/td>\nselectInstancesFiredTriggerRecords
                                updateTriggerStatesForJobFromOtherState
                                storeTrigger
                                deleteFiredTriggers
                                selectFiredTriggerRecords
                                removeTrigger
                                deleteSchedulerState<\/td>\n
                                \u96c6\u7fa4\u6709\u7ed3\u70b9faied\uff0c\u8ba9JOB\u80fd\u91cd\u65b0\u6267\u884c\u3002<\/td>\n<\/tr>\n
                                executeInLock
                                \u6570\u636e\u5e93\u96c6\u7fa4\u91cc\u7b49\u540c\u4e8e
                                executeInNonManagedTXLock<\/td>\n
                                storeJobAndTrigger<\/td>\nupdateJobDetail insertJobDetail
                                triggerExists
                                selectJobDetail
                                updateTrigger insertTrigger<\/td>\n
                                \u4fdd\u5b58JOB\u548cTRIGGER\u914d\u7f6e<\/td>\n<\/tr>\n
                                storeJob<\/td>\n <\/td>\n\u4fdd\u5b58JOB<\/td>\n<\/tr>\n
                                removeJob<\/td>\n <\/td>\n\u5220\u9664JOB<\/td>\n<\/tr>\n
                                removeJobs<\/td>\n <\/td>\n\u6279\u91cf\u5220\u9664JOB<\/td>\n<\/tr>\n
                                removeTriggers<\/td>\n <\/td>\n\u6279\u91cf\u5220\u9664triggers<\/td>\n<\/tr>\n
                                storeJobsAndTriggers<\/td>\n <\/td>\n\u4fdd\u5b58JOB\u548c\u591a\u4e2atrigger\u914d\u7f6e<\/td>\n<\/tr>\n
                                removeTrigger<\/td>\n <\/td>\n\u5220\u9664trigger<\/td>\n<\/tr>\n
                                replaceTrigger<\/td>\n <\/td>\n\u66ff\u6362trigger<\/td>\n<\/tr>\n
                                storeCalendar<\/td>\n <\/td>\n\u4fdd\u5b58\u5b9a\u65f6\u65e5\u671f<\/td>\n<\/tr>\n
                                removeCalendar<\/td>\n <\/td>\n\u5220\u9664\u5b9a\u65f6\u65e5\u671f<\/td>\n<\/tr>\n
                                clearAllSchedulingData<\/td>\n <\/td>\n\u6e05\u9664\u6240\u6709\u5b9a\u65f6\u6570\u636e<\/td>\n<\/tr>\n
                                pauseTrigger<\/td>\n <\/td>\n\u505c\u6b62\u89e6\u53d1\u5668<\/td>\n<\/tr>\n
                                pauseJob<\/td>\n <\/td>\n\u505c\u6b62\u4efb\u52a1<\/td>\n<\/tr>\n
                                pauseJobs<\/td>\n <\/td>\n\u6279\u91cf\u505c\u6b62\u4efb\u52a1<\/td>\n<\/tr>\n
                                resumeTrigger<\/td>\n <\/td>\n\u6062\u590d\u89e6\u53d1\u5668<\/td>\n<\/tr>\n
                                resumeJob<\/td>\n <\/td>\n\u6062\u590d\u4efb\u52a1<\/td>\n<\/tr>\n
                                resumeJobs<\/td>\n <\/td>\n\u6279\u91cf\u6062\u590d\u4efb\u52a1<\/td>\n<\/tr>\n
                                pauseTriggers<\/td>\n <\/td>\n\u6279\u91cf\u505c\u6b62\u89e6\u53d1\u5668<\/td>\n<\/tr>\n
                                resumeTriggers<\/td>\n <\/td>\n\u6279\u91cf\u6062\u590d\u89e6\u53d1\u5668<\/td>\n<\/tr>\n
                                pauseAll<\/td>\n <\/td>\n\u505c\u6b62\u6240\u6709<\/td>\n<\/tr>\n
                                resumeAll<\/td>\n <\/td>\n\u6062\u590d\u6240\u6709<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

                                \u2014<\/p>\n

                                2\u3001STATE_TRIGGER
                                \u5b9e\u73b0\u90fd\u5728JobStoreSupport\u7c7b <\/p>\n\n\n\n\n\n
                                \u52a0\u9501\u7c7b\u578b<\/td>\n\u52a0\u9501\u65b9\u6cd5<\/td>\n\u5e95\u5c42\u6570\u636e\u5e93\u64cd\u4f5c<\/td>\n\u5907\u6ce8<\/td>\n<\/tr>\n
                                obtainLock<\/td>\ndoCheckin<\/td>\nclusterCheckIn<\/td>\n\u5224\u65ad\u96c6\u7fa4\u72b6\u6001
                                \u5148\u7528LOCK_STATE_ACCESS\u9501\u96c6\u7fa4\u72b6\u6001
                                \u518d\u7528LOCK_TRIGGER_ACCESS\u6062\u590d\u96c6\u7fa4\u8fd0\u884c<\/td>\n<\/tr>\n
                                 <\/td>\n <\/td>\n <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

                                \u2014<\/p>\n

                                 <\/p>\n

                                <\/span><\/p>\n

                                    \u516d\u3001\u53c2\u8003\u8d44\u6599<\/h2>\n

                                    <\/p>\n

                                  \n
                                1. Quartz Documentation http:\/\/quartz-scheduler.org\/documentation<\/li>\n
                                2. spring javadoc-api http:\/\/docs.spring.io\/spring\/docs\/4.3.0.BUILD-SNAPSHOT\/javadoc-api\/<\/li>\n
                                3. \u57fa\u4e8eQuartz\u5f00\u53d1\u4f01\u4e1a\u7ea7\u4efb\u52a1\u8c03\u5ea6\u5e94\u7528 https:\/\/www.ibm.com\/developerworks\/cn\/opensource\/os-cn-quartz\/<\/li>\n
                                4. quartz\u5e94\u7528\u4e0e\u96c6\u7fa4\u539f\u7406\u5206\u6790 http:\/\/tech.meituan.com\/mt-crm-quartz.html<\/li>\n
                                5. quartz\u8be6\u89e32\uff1aquartz\u7531\u6d45\u5165\u6df1 http:\/\/ecmcug.itpub.net\/11627468\/viewspace-1763498\/<\/li>\n
                                6. quartz\u8be6\u89e34\uff1aquartz\u7ebf\u7a0b\u7ba1\u7406 http:\/\/blog.itpub.net\/11627468\/viewspace-1766967\/<\/li>\n
                                7. quartz\u5b66\u4e60\u7b14\u8bb0 http:\/\/www.cnblogs.com\/yunxuange\/archive\/2012\/08\/28\/2660141.html<\/li>\n
                                8. quartz\u96c6\u7fa4\u8c03\u5ea6\u673a\u5236\u8c03\u7814\u53ca\u6e90\u7801\u5206\u6790 http:\/\/demo.netfoucs.com\/gklifg\/article\/details\/27090179<\/li>\n<\/ol>\n

                                   <\/p>\n

                                  <\/span><\/p>\n

                                       \u603b\u7ed3<\/h2>\n

                                         \u901a\u8fc7\u8fd9\u6bb5\u65f6\u95f4\u5bf9quartz\u8d44\u6599\u7684\u6574\u7406\u548c\u7ed3\u5408\u5de5\u4f5c\u4e2d\u7684\u8fd0\u7528\uff0c\u6df1\u5165\u7406\u89e3\u4e86quartz\u8fd9\u4e00\u4f18\u79c0\u7684\u8c03\u5ea6\u6846\u67b6\u3002\u5728\u6280\u672f\u8fd9\u6761\u8def\u4e0a\uff0c\u505a\u6280\u672f\u5343\u4e07\u4e0d\u8981\u6d45\u5c1d\u8f84\u6b62\uff0c\u4e00\u5b9a\u8981\u6df1\u5165\u7684\u53bb\u7406\u89e3\u6240\u7528\u7684\u4e1c\u897f\uff0c\u624d\u4f1a\u4f7f\u81ea\u5df1\u7684\u80fd\u529b\u63d0\u5347\uff0c\u6b64\u5916\uff0c\u4e00\u4e9b\u7cfb\u7edf\u7684\u77e5\u8bc6\u5206\u6790\u5bf9\u81ea\u5df1\u548c\u4ed6\u4eba\u90fd\u662f\u5341\u5206\u6709\u76ca\u7684\u3002<\/p>\n

                                  \u8f6c\u8f7d\uff1ahttps:\/\/my.oschina.net\/songhongxu\/blog\/802574<\/p>\n

                                  \t\t\t\t<script>\n\t\t\t\t\t(function(){\n\t\t\t\t\t\tfunction setArticleH(btnReadmore,posi){\n\t\t\t\t\t\t\tvar winH = $(window).height();\n\t\t\t\t\t\t\tvar articleBox = $(\"div.article_content\");\n\t\t\t\t\t\t\tvar artH = articleBox.height();\n\t\t\t\t\t\t\tif(artH > winH*posi){\n\t\t\t\t\t\t\t\tarticleBox.css({\n\t\t\t\t\t\t\t\t\t'height':winH*posi+'px',\n\t\t\t\t\t\t\t\t\t'overflow':'hidden'\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\tbtnReadmore.click(function(){\n\t\t\t\t\t\t\t\t\tarticleBox.removeAttr(\"style\");\n\t\t\t\t\t\t\t\t\t$(this).parent().remove();\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\tbtnReadmore.parent().remove();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvar btnReadmore = $(\"#btn-readmore\");\n\t\t\t\t\t\tif(btnReadmore.length>0){\n\t\t\t\t\t\t\tif(currentUserName){\n\t\t\t\t\t\t\t\tsetArticleH(btnReadmore,3);\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\tsetArticleH(btnReadmore,1.2);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t})()\n\t\t\t\t<\/script>\n\t\t\t\t<\/article>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"quartz\u539f\u7406\u5206\u6790_\u5355\u7247\u673a\u5b9a\u65f6\u5668\u539f\u7406[\u901a\u4fd7\u6613\u61c2]  \u4e00\u3001Quartz\u57fa\u672c\u4ecb\u7ecd      1.1 Q...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8788"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=8788"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8788\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}