{"id":902,"date":"2023-03-27T01:15:36","date_gmt":"2023-03-26T17:15:36","guid":{"rendered":"http:\/\/codermr.com\/?p=902"},"modified":"2023-03-27T21:18:33","modified_gmt":"2023-03-27T13:18:33","slug":"xxl-job3","status":"publish","type":"post","link":"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/","title":{"rendered":"xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3"},"content":{"rendered":"\n<p>\u5728 <a href=\"http:\/\/codermr.com\/index.php\/2023\/02\/27\/xxl-job1\/\">xxl-job \u539f\u7406\u8bb2\u89e3\uff08\u4e00\uff09 <\/a>\u548c <a href=\"http:\/\/codermr.com\/index.php\/2023\/03\/26\/xxl-job2\/\">xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e8c\uff09\uff1a\u4e3b\u8981\u7c7b <\/a>\u4e24\u7bc7\u6587\u7ae0\u4e2d\u6211\u5206\u6790\u4e86 xxl-job \u7684\u5de5\u4f5c\u539f\u7406\uff0c\u672c\u6765\u60f3\u4e00\u7bc7\u6587\u7ae0\u5199\u5b8c\uff0c\u7ed3\u679c\u53d1\u73b0\u5185\u5bb9\u592a\u591a\uff0c\u4e8e\u662f\u53c8\u5f00\u4e00\u7bc7 &#8211; \u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u8bb2 xxl-job \u7684\u8c03\u5ea6\u4e2d\u5fc3\u7684\u5de5\u4f5c\u539f\u7406\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">XxlJobScheduler <\/h3>\n\n\n\n<p>\u76f4\u63a5\u5f00\u95e8\u89c1\u5c71\u7684\u8bf4\uff0c\u8c03\u5ea6\u4e2d\u5fc3\u7684\u65b9\u6cd5\u5165\u53e3\u5728 com.xxl.job.admin.core.scheduler.XxlJobScheduler \u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public void init() throws Exception {\n    \/\/ init i18n\n    initI18n();\n\n    \/\/ admin registry monitor run\u2588\u2588\u4e0d\u505c\u8f6e\u8be2\u68c0\u6d4b xxl_job_registry \u8868\u4e2d\u5df2\u7ecfdead\u7684\u673a\u5668\u5217\u8868\u5e76\u66f4\u65b0 xxl_job_registry \u548c xxl_job_group \u2588\u2588\n    JobRegistryMonitorHelper.getInstance().start();\n\n    \/\/ admin fail-monitor run\n    JobFailMonitorHelper.getInstance().start();\n\n    \/\/ admin lose-monitor run\n    JobLosedMonitorHelper.getInstance().start();\n\n    \/\/ admin trigger pool start\n    JobTriggerPoolHelper.toStart();\n\n    \/\/ admin log report start\n    JobLogReportHelper.getInstance().start();\n\n    \/\/ start-schedule\n    JobScheduleHelper.getInstance().start();\n\n    logger.info(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; init xxl-job admin success.\");\n}<\/code><\/pre>\n\n\n\n<p>\u4e3b\u8981\u5173\u6ce8 JobRegistryMonitorHelper.getInstance().start(); \u548c JobScheduleHelper.getInstance().start(); \u4e24\u884c\u4ee3\u7801\u3002<\/p>\n\n\n\n<p>\u4e0d\u8fc7\u8fd8\u662f\u5f97\u5148\u4ece XxlJobTrigger \u8bf4\u8d77\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">XxlJobTrigger <\/h3>\n\n\n\n<p>XxlJobTrigger \u4e2d\u7684 trigger \u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public static void trigger(int jobId, TriggerTypeEnum triggerType, int failRetryCount,\n      String executorShardingParam, String executorParam, String addressList) {\n\n        \/\/ load data\n        XxlJobInfo jobInfo = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(jobId);\n        if (jobInfo == null) {\n            logger.warn(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; trigger fail, jobId invalid\uff0cjobId={}\", jobId);\n            return;\n        }\n        if (executorParam != null) {\n            jobInfo.setExecutorParam(executorParam);\n        }\n        int finalFailRetryCount = failRetryCount &gt;= 0 ? failRetryCount : jobInfo.getExecutorFailRetryCount();\n        XxlJobGroup group = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().load(jobInfo.getJobGroup());\n\n        \/\/ cover addressList\n        if (addressList != null &amp;&amp; addressList.trim().length() &gt; 0) {\n            group.setAddressType(1);\n            group.setAddressList(addressList.trim());\n        }\n        ......\n         processTrigger(group, jobInfo, finalFailRetryCount, triggerType, shardingParam&#91;0], shardingParam&#91;1]);\n}<\/code><\/pre>\n\n\n\n<p>trigger \u5c31\u662f\u201c\u89e6\u53d1\u201d\u7684\u610f\u601d\uff0c\u8be5\u65b9\u6cd5\u5c31\u662f\u89e6\u53d1\u4e00\u6b21\u5b9a\u65f6\u4efb\u52a1\uff0c\u5165\u53c2\u6709 jobId\u3001triggerType\u3001\u5206\u7247\u7b56\u7565\u7b49\u53c2\u6570\uff0c\u6700\u7ec8\u4f1a\u8c03\u7528 processTrigger \u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private static void processTrigger(XxlJobGroup group, XxlJobInfo jobInfo, int finalFailRetryCount, TriggerTypeEnum triggerType, int index,\n  int total) {\n\n    \/\/ \u3010\u83b7\u53d6\u963b\u585e\u7b56\u7565\u3011\n    ExecutorBlockStrategyEnum blockStrategy = ExecutorBlockStrategyEnum.match(jobInfo.getExecutorBlockStrategy(),\n      ExecutorBlockStrategyEnum.SERIAL_EXECUTION);  \/\/ block strategy\n    \/\/ \u3010\u83b7\u53d6\u8def\u7531\u7b56\u7565\u3011\n    ExecutorRouteStrategyEnum executorRouteStrategyEnum = ExecutorRouteStrategyEnum.match(jobInfo.getExecutorRouteStrategy(),\n      null);\n    \/\/ \u3010(\u5206\u7247\u5e7f\u64ad)\uff1a\u5e7f\u64ad\u89e6\u53d1\u5bf9\u5e94\u96c6\u7fa4\u4e2d\u6240\u6709\u673a\u5668\u6267\u884c\u4e00\u6b21\u4efb\u52a1\u3011\n    String shardingParam = (ExecutorRouteStrategyEnum.SHARDING_BROADCAST == executorRouteStrategyEnum) ? String.valueOf(index).concat(\"\/\")\n      .concat(String.valueOf(total)) : null;\n\n    \/\/ 1\u3001save log-id\n    XxlJobLog jobLog = new XxlJobLog();\n    jobLog.setJobGroup(jobInfo.getJobGroup());\n    jobLog.setJobId(jobInfo.getId());\n    jobLog.setTriggerTime(new Date());\n    XxlJobAdminConfig.getAdminConfig().getXxlJobLogDao().save(jobLog);\n    logger.debug(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; xxl-job trigger start, jobId:{}\", jobLog.getId());\n\n    \/\/ 2\u3001init trigger-param\n    TriggerParam triggerParam = new TriggerParam();\n    triggerParam.setJobId(jobInfo.getId());\n    triggerParam.setExecutorHandler(jobInfo.getExecutorHandler());\n    triggerParam.setExecutorParams(jobInfo.getExecutorParam());\n    triggerParam.setExecutorBlockStrategy(jobInfo.getExecutorBlockStrategy());\n    triggerParam.setExecutorTimeout(jobInfo.getExecutorTimeout());\n    triggerParam.setLogId(jobLog.getId());\n    triggerParam.setLogDateTime(jobLog.getTriggerTime().getTime());\n    triggerParam.setGlueType(jobInfo.getGlueType());\n    triggerParam.setGlueSource(jobInfo.getGlueSource());\n    triggerParam.setGlueUpdatetime(jobInfo.getGlueUpdatetime().getTime());\n    triggerParam.setBroadcastIndex(index);\n    triggerParam.setBroadcastTotal(total);\n    \/\/ 3\u3001init address\n    String address = null;\n    ReturnT&lt;String&gt; routeAddressResult = null;\n    if (group.getRegistryList() != null &amp;&amp; !group.getRegistryList().isEmpty()) {\n        if (ExecutorRouteStrategyEnum.SHARDING_BROADCAST == executorRouteStrategyEnum) {\n            \/\/ \u662f\u5206\u7247\u5e7f\u64ad\n            if (index &lt; group.getRegistryList().size()) {\n                address = group.getRegistryList().get(index);\n            } else {\n                address = group.getRegistryList().get(0);\n            }\n        } else {\n            \/\/ \u4e0d\u662f\u5206\u7247\u5e7f\u64ad\uff0c\u5219\u6839\u636e\u8def\u7531\u7b56\u7565\uff0c\u83b7\u53d6\u8981\u6267\u884c\u4efb\u52a1\u7684\u6267\u884c\u5668\u5730\u5740\n            routeAddressResult = executorRouteStrategyEnum.getRouter().route(triggerParam, group.getRegistryList());\n            if (routeAddressResult.getCode() == ReturnT.SUCCESS_CODE) {\n                address = routeAddressResult.getContent();\n            }\n        }\n    } else {\n        routeAddressResult = new ReturnT&lt;String&gt;(ReturnT.FAIL_CODE, I18nUtil.getString(\"jobconf_trigger_address_empty\"));\n    }\n\n    \/\/ 4\u3001trigger remote executor\n    ReturnT&lt;String&gt; triggerResult = null;\n    if (address != null) {\n        \/\/ \u901a\u77e5\u6267\u884c\u5668\u6267\u884c\u5b9a\u65f6\u4efb\u52a1\n        triggerResult = runExecutor(triggerParam, address);\n    } else {\n        triggerResult = new ReturnT&lt;String&gt;(ReturnT.FAIL_CODE, null);\n    }\n    .....\n}<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u5df2\u7ecf\u6839\u636e\u4e0d\u540c\u7684\u8def\u7531\u7b56\u7565\uff0c\u5f97\u5230\u8981\u6267\u884c\u5b9a\u65f6\u4efb\u52a1\u7684\u6267\u884c\u5668\u5730\u5740\uff0c\u4e0b\u9762\u7684 runExecutor \u65b9\u6cd5\u4f1a\u5c01\u88c5\u5b9a\u65f6\u4efb\u52a1\u7684\u5404\u79cd\u53c2\u6570\uff0c\u7136\u540e\u8c03\u7528 runExecutor \u65b9\u6cd5\u901a\u77e5\u5bf9\u5e94\u7684\u6267\u884c\u5668\u6267\u884c\u5b9a\u65f6\u4efb\u52a1\uff08\u6ce8\u610f\uff0c\u662f Http \u65b9\u5f0f\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public static ReturnT&lt;String&gt; runExecutor(TriggerParam triggerParam, String address) {\n    ReturnT&lt;String&gt; runResult = null;\n    try {\n        \/\/ \u83b7\u53d6\u5ba2\u6237\u7aef\u5730\u5740\n        ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(address);\n        runResult = executorBiz.run(triggerParam);\n    } catch (Exception e) {\n        logger.error(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; xxl-job trigger error, please check if the executor&#91;{}] is running.\", address, e);\n        runResult = new ReturnT&lt;String&gt;(ReturnT.FAIL_CODE, ThrowableUtil.toString(e));\n    }\n\n    StringBuffer runResultSB = new StringBuffer(I18nUtil.getString(\"jobconf_trigger_run\") + \"\uff1a\");\n    runResultSB.append(\"&lt;br&gt;address\uff1a\").append(address);\n    runResultSB.append(\"&lt;br&gt;code\uff1a\").append(runResult.getCode());\n    runResultSB.append(\"&lt;br&gt;msg\uff1a\").append(runResult.getMsg());\n\n    runResult.setMsg(runResultSB.toString());\n    return runResult;\n}<\/code><\/pre>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u6267\u884c\u5b9a\u65f6\u4efb\u52a1\u8c03\u7528\u7684\u662f executorBiz.run(&#8230;) \u65b9\u6cd5\uff0c\u6b64\u5904\u7684 executorBiz \u7684\u5b9e\u73b0\u7c7b\u662f ExecutorBizClient \uff0c\u5df2\u7ecf\u5728\u8fd9\u7bc7\u6587\u7ae0\u91cc\u8bb2\u8fc7\uff1a<a href=\"http:\/\/codermr.com\/index.php\/2023\/03\/26\/xxl-job2\/\">xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e8c\uff09\uff1a\u4e3b\u8981\u7c7b &#8211; \u7801\u5148\u751f\u7684\u535a\u5ba2 (codermr.com)<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">JobScheduleHelper <\/h3>\n\n\n\n<p>\u4e0a\u9762\u8bb2\u7684\u662f\u89e6\u53d1\u4e00\u6b21\u5b9a\u65f6\u4efb\u52a1\u7684\u903b\u8f91\uff0c\u90a3\u4e48\u8c03\u5ea6\u4e2d\u5fc3\u662f\u600e\u4e48\u6309 Cron \u8868\u8fbe\u5f0f\u4e2d\u914d\u7f6e\u7684\u89c4\u5219\u5bf9\u5b9a\u65f6\u4efb\u52a1\u8fdb\u884c\u8c03\u5ea6\u7684\u5462\uff1f\u7b54\u6848\u5c31\u5728 JobScheduleHelper \u91cc\u9762\uff0cJobScheduleHelper \u4e3b\u8981\u903b\u8f91\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>try {\n\n    conn = XxlJobAdminConfig.getAdminConfig().getDataSource().getConnection();\n    connAutoCommit = conn.getAutoCommit();\n    conn.setAutoCommit(false);\n\n    preparedStatement = conn.prepareStatement(\"select * from xxl_job_lock where lock_name = 'schedule_lock' for update\");\n    preparedStatement.execute();\n\n    \/\/ tx start\n\n    \/\/ 1\u3001pre read\n    long nowTime = System.currentTimeMillis();\n\n    \/\/ \u2588\u2588\u2588\u2588 \u83b7\u53d6\u672a\u6765 5 \u79d2\u5185\u8981\u6267\u884c\u7684\u5b9a\u65f6\u4efb\u52a1 \u2588\u2588\u2588\u2588\n    List&lt;XxlJobInfo&gt; scheduleList = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao()\n      .scheduleJobQuery(nowTime + PRE_READ_MS, preReadCount);\n\n    if (scheduleList != null &amp;&amp; scheduleList.size() &gt; 0) {\n        \/\/ 2\u3001push time-ring\n        for (XxlJobInfo jobInfo : scheduleList) {\n\n            \/\/ time-ring jump\n            if (nowTime &gt; jobInfo.getTriggerNextTime() + PRE_READ_MS) {\n                \/\/\u3010\u60c5\u51b5\u4e00\uff1anowTime\u6bd4jobInfo\u4e2d\u7684\"TriggerNextTime+5\u79d2\"\u8fd8\u5927,\u8bf4\u660e\u8be5\u5b9a\u65f6\u4efb\u52a1\u8be5\u6267\u884c\u65f6\u6ca1\u6709\u6267\u884c,\u8c03\u7528refreshNextValidTime(jobInfo, new Date());\u5237\u65b0\u8be5jobInfo\u4e0b\u6b21\u6267\u884c\u5bf9\u5e94\u7684\u65f6\u95f4,\u6ce8\u610f\u5237\u65b0\u4e86\u65f6\u95f4\u4f46\u6ca1\u6709\u6267\u884c\u8be5jobInfo\u3011\n                \/\/ 2.1\u3001trigger-expire &gt; 5s\uff1apass &amp;&amp; make next-trigger-time\n                logger.warn(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; xxl-job, schedule misfire, jobId = \" + jobInfo.getId());\n\n                \/\/ fresh next\n                refreshNextValidTime(jobInfo, new Date());\n\n            } else if (nowTime &gt; jobInfo.getTriggerNextTime()) {\n                \/\/\u3010\u60c5\u51b5\u4e8c\uff1anowTime\u6bd4jobInfo\u4e2d\u7684\"TriggerNextTime\"\u5927,\u4f46\u662f\u5c0f\u4e8e\"TriggerNextTime+5\u79d2\",\u8bf4\u660e\u8be5\u5b9a\u65f6\u4efb\u52a1\u8be5\u6267\u884c\u65f6\u6ca1\u6709\u6267\u884c,\u4f46\u65f6\u95f4\u5dee\u5c0f\u4e8e5s\uff0c\u90a3\u5c31\u76f4\u63a5\u6267\u884cjobInfo,\u5e76\u5237\u65b0\u8be5jobInfo\u4e0b\u6b21\u6267\u884c\u5bf9\u5e94\u7684\u65f6\u95f4\u3011\n\n                \/\/ 2.2\u3001trigger-expire &lt; 5s\uff1adirect-trigger &amp;&amp; make next-trigger-time\n\n                \/\/ 1\u3001trigger\n                JobTriggerPoolHelper.trigger(jobInfo.getId(), TriggerTypeEnum.CRON, -1, null, null, null);\n                logger.debug(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; xxl-job, schedule push trigger : jobId = \" + jobInfo.getId());\n\n                \/\/ 2\u3001fresh next\n                refreshNextValidTime(jobInfo, new Date());\n\n                \/\/ next-trigger-time in 5s, pre-read again\n                if (jobInfo.getTriggerStatus() == 1 &amp;&amp; nowTime + PRE_READ_MS &gt; jobInfo.getTriggerNextTime()) {\n                    \/\/\u3010\u60c5\u51b5\u4e09\uff1a\u5982\u679c\u8be5\u5b9a\u65f6\u4efb\u52a1\u662f\"\u8fd0\u884c\u4e2d\"\u5e76\u4e14\"nowTime+5\u79d2\"\u5927\u4e8ejobInfo\u7684TriggerNextTime\uff0c\u5373\u8be5\u4efb\u52a1\u662f\"\u8fd0\u884c\u4e2d\"\u72b6\u6001\u5e76\u4e145\u79d2\u5185\u5c06\u8981\u6267\u884c\uff0c\u5219\uff1a\u3011\n                    \/\/\u3010\u5bf9TriggerNextTime\u9664\u4ee560\u53d6\u4f59\u6570\u3011\n                    \/\/ 1\u3001make ring second\n                    int ringSecond = (int) ((jobInfo.getTriggerNextTime() \/ 1000) % 60);\n                    \/\/\u3010\u5c06\u8be5\u5b9a\u65f6\u4efb\u52a1\u653e\u5230\u4e00\u4e2aMap\u4e2d\uff0cMap\u7684key\u662f\u4ece0\u523059\u3011\n                    \/\/ 2\u3001push time ring\n                    pushTimeRing(ringSecond, jobInfo.getId());\n\n                    \/\/ 3\u3001fresh next\n                    refreshNextValidTime(jobInfo, new Date(jobInfo.getTriggerNextTime()));\n\n                }\n\n            } else {\n                \/\/ 2.3\u3001trigger-pre-read\uff1atime-ring trigger &amp;&amp; make next-trigger-time\n\n                \/\/ 1\u3001make ring second\n                int ringSecond = (int) ((jobInfo.getTriggerNextTime() \/ 1000) % 60);\n\n                \/\/ 2\u3001push time ring\n                pushTimeRing(ringSecond, jobInfo.getId());\n\n                \/\/ 3\u3001fresh next\n                refreshNextValidTime(jobInfo, new Date(jobInfo.getTriggerNextTime()));\n\n            }\n\n        }\n\n        \/\/ 3\u3001update trigger info\n        for (XxlJobInfo jobInfo : scheduleList) {\n            XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().scheduleUpdate(jobInfo);\n        }\n\n    } else {\n        preReadSuc = false;\n    }\n\n    \/\/ tx stop\n\n} catch (Exception e) {\n    if (!scheduleThreadToStop) {\n        logger.error(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; xxl-job, JobScheduleHelper#scheduleThread error:{}\", e);\n    }\n}<\/code><\/pre>\n\n\n\n<p>ringData \u662f\u4e00\u4e2a Map\uff0ckey \u662f\u4ece 0 \u5230 59\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private volatile static Map&lt;Integer, List&lt;Integer&gt;&gt; ringData = new ConcurrentHashMap&lt;&gt;();\nprivate void pushTimeRing(int ringSecond, int jobId) {\n    \/\/ push async ring\n    List&lt;Integer&gt; ringItemData = ringData.get(ringSecond);\n    if (ringItemData == null) {\n        ringItemData = new ArrayList&lt;Integer&gt;();\n        ringData.put(ringSecond, ringItemData);\n    }\n    ringItemData.add(jobId);\n\n    logger.debug(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; xxl-job, schedule push time-ring : \" + ringSecond + \" = \" + Arrays.asList(ringItemData));\n}<\/code><\/pre>\n\n\n\n<p>\u4e0b\u9762\u7684\u7ebf\u7a0b\uff0c\u5c31\u662f\u5b9a\u65f6\u4efb\u52a1&#8221;\u5b9a\u65f6\u89e6\u53d1&#8221;\u7684\u4e3b\u8981\u903b\u8f91\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> ringThread = new Thread(new Runnable() {\n        @Override\n        public void run() {\n\n            \/\/ align second\n            try {\n                \/\/\u3010\u4f11\u7720\u65f6\u95f4\u5c0f\u4e8e1s\u3011\n                TimeUnit.MILLISECONDS.sleep(1000 - System.currentTimeMillis() % 1000);\n            } catch (InterruptedException e) {\n                if (!ringThreadToStop) {\n                    logger.error(e.getMessage(), e);\n                }\n            }\n\n            while (!ringThreadToStop) {\n\n                try {\n                    \/\/ second data\n                    List&lt;Integer&gt; ringItemData = new ArrayList&lt;&gt;();\n                    int nowSecond = Calendar.getInstance().get(Calendar.SECOND);   \/\/ \u907f\u514d\u5904\u7406\u8017\u65f6\u592a\u957f\uff0c\u8de8\u8fc7\u523b\u5ea6\uff0c\u5411\u524d\u6821\u9a8c\u4e00\u4e2a\u523b\u5ea6\uff1b\n                    for (int i = 0; i &lt; 2; i++) {\n                        List&lt;Integer&gt; tmpData = ringData.remove((nowSecond + 60 - i) % 60);\/\/\u3010\u83b7\u53d6\u8fd91\u79d2\u8981\u6267\u884c\u7684\u4efb\u52a1\u3011\n                        if (tmpData != null) {\n                            ringItemData.addAll(tmpData);\n                        }\n                    }\n\n                    \/\/ ring trigger\n                    logger.debug(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; xxl-job, time-ring beat : \" + nowSecond + \" = \" + Arrays.asList(ringItemData));\n                    if (ringItemData.size() &gt; 0) {\n                        \/\/ do trigger\n                        for (int jobId : ringItemData) {\n                            \/\/ do trigger\u3010\u6267\u884c\u3011\n                            JobTriggerPoolHelper.trigger(jobId, TriggerTypeEnum.CRON, -1, null, null, null);\n                        }\n                        \/\/ clear\n                        ringItemData.clear();\n                    }\n                } catch (Exception e) {\n                    if (!ringThreadToStop) {\n                        logger.error(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; xxl-job, JobScheduleHelper#ringThread error:{}\", e);\n                    }\n                }\n\n                \/\/ next second, align second\n                try {\n                    \/\/\u3010\u4f11\u7720\u65f6\u95f4\u5c0f\u4e8e1s\u3011\n                    TimeUnit.MILLISECONDS.sleep(1000 - System.currentTimeMillis() % 1000);\n                } catch (InterruptedException e) {\n                    if (!ringThreadToStop) {\n                        logger.error(e.getMessage(), e);\n                    }\n                }\n            }\n            logger.info(\"&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; xxl-job, JobScheduleHelper#ringThread stop\");\n        }\n    });\n    ringThread.setDaemon(true);\n    ringThread.setName(\"xxl-job, admin JobScheduleHelper#ringThread\");\n    ringThread.start();\n}<\/code><\/pre>\n\n\n\n<p>\u201c\u4f11\u7720\u65f6\u95f4\u5c0f\u4e8e1s\u201d\u5373 while \u5faa\u73af\u6bcf 1s \u6267\u884c\u4e00\u6b21\uff0c\u83b7\u53d6\u8fd9 1s \u5185\u8981\u6267\u884c\u7684\u5b9a\u65f6\u4efb\u52a1\uff0c\u89e6\u53d1\u4e00\u6b21\u6267\u884c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">JobRegistryMonitorHelper<\/h3>\n\n\n\n<p>\u5728\u524d\u4e24\u7bc7\u6587\u7ae0\u4e2d\u5df2\u7ecf\u8bb2\u8fc7\u4e86\uff0c\u6267\u884c\u5668\u4f1a\u6bcf\u9694 30s \u5f80\u8c03\u5ea6\u4e2d\u5fc3\u4e0a\u6ce8\u518c\u4e00\u6b21\uff08\u65b0\u589e\u6216\u66f4\u65b0 xxl_job_registry \u8868\uff09\uff0c\u800c\u8c03\u5ea6\u4e2d\u5fc3\u540c\u6837\u4f1a\u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\u68c0\u6d4b\u4e00\u4e0b xxl_job_registry \u4e2d\u54ea\u4e9b\u6267\u884c\u5668\u8fd8\u5b58\u6d3b\u7740\uff0c\u5177\u4f53\u4ee3\u7801\u5728 com.xxl.job.admin.core.thread.JobRegistryMonitorHelper#start \u4e2d\uff0c\u903b\u8f91\u5f88\u7b80\u5355\uff0c\u8c03\u5ea6\u4e2d\u5fc3\u4f1a\u6bcf 30s \u67e5\u8be2\u4e00\u6b21 xxl_job_registry \u8868\u770b\u54ea\u4e9b\u8bb0\u5f55\u7684\u66f4\u65b0\u65f6\u95f4 90s \u90fd\u6ca1\u6709\u53d8\u5316\uff0c\u8fd9\u4e9b\u6267\u884c\u5668\u5c06\u88ab\u8c03\u5ea6\u4e2d\u5fc3\u4ece xxl_job_registry \u8868\u4e2d\u5220\u9664\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u5b8c\u3002<\/h1>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 xxl-job \u539f\u7406\u8bb2\u89e3\uff08\u4e00\uff09 \u548c xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e8c\uff09\uff1a\u4e3b\u8981\u7c7b \u4e24\u7bc7\u6587\u7ae0\u4e2d\u6211\u5206\u6790\u4e86 xxl-jo&#8230;<\/p>\n","protected":false},"author":1,"featured_media":729,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[51],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3 - \u7801\u5148\u751f\u7684\u535a\u5ba2<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3 - \u7801\u5148\u751f\u7684\u535a\u5ba2\" \/>\n<meta property=\"og:description\" content=\"\u5728 xxl-job \u539f\u7406\u8bb2\u89e3\uff08\u4e00\uff09 \u548c xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e8c\uff09\uff1a\u4e3b\u8981\u7c7b \u4e24\u7bc7\u6587\u7ae0\u4e2d\u6211\u5206\u6790\u4e86 xxl-jo...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/\" \/>\n<meta property=\"og:site_name\" content=\"\u7801\u5148\u751f\u7684\u535a\u5ba2\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-26T17:15:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-27T13:18:33+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/codermr.com\/wp-content\/uploads\/2023\/02\/xxl1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"221\" \/>\n\t<meta property=\"og:image:height\" content=\"218\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"\u7801\u5148\u751f\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/mrcode2021\" \/>\n<meta name=\"twitter:site\" content=\"@mrcode2021\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u7801\u5148\u751f\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/\"},\"author\":{\"name\":\"\u7801\u5148\u751f\",\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf\"},\"headline\":\"xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3\",\"datePublished\":\"2023-03-26T17:15:36+00:00\",\"dateModified\":\"2023-03-27T13:18:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/\"},\"wordCount\":74,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf\"},\"keywords\":[\"xxl-job\"],\"articleSection\":[\"JAVA\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/\",\"url\":\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/\",\"name\":\"xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3 - \u7801\u5148\u751f\u7684\u535a\u5ba2\",\"isPartOf\":{\"@id\":\"http:\/\/codermr.com\/#website\"},\"datePublished\":\"2023-03-26T17:15:36+00:00\",\"dateModified\":\"2023-03-27T13:18:33+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"http:\/\/codermr.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/codermr.com\/#website\",\"url\":\"http:\/\/codermr.com\/\",\"name\":\"\u7801\u5148\u751f\u7684\u535a\u5ba2\",\"description\":\"\u6b22 \u8fce \u4e0b \u8f7d \u6211 \u5f00 \u53d1 \u7684 \u5404 \u7aef \u8f6f \u4ef6 \u548c APP\",\"publisher\":{\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/codermr.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf\",\"name\":\"\u7801\u5148\u751f\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/codermr.com\/wp-content\/uploads\/2023\/02\/wukong.jpg\",\"contentUrl\":\"http:\/\/codermr.com\/wp-content\/uploads\/2023\/02\/wukong.jpg\",\"width\":400,\"height\":400,\"caption\":\"\u7801\u5148\u751f\"},\"logo\":{\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/codermr.com\",\"https:\/\/twitter.com\/https:\/\/twitter.com\/mrcode2021\"],\"url\":\"http:\/\/codermr.com\/index.php\/author\/coderma\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3 - \u7801\u5148\u751f\u7684\u535a\u5ba2","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/","og_locale":"zh_CN","og_type":"article","og_title":"xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3 - \u7801\u5148\u751f\u7684\u535a\u5ba2","og_description":"\u5728 xxl-job \u539f\u7406\u8bb2\u89e3\uff08\u4e00\uff09 \u548c xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e8c\uff09\uff1a\u4e3b\u8981\u7c7b \u4e24\u7bc7\u6587\u7ae0\u4e2d\u6211\u5206\u6790\u4e86 xxl-jo...","og_url":"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/","og_site_name":"\u7801\u5148\u751f\u7684\u535a\u5ba2","article_published_time":"2023-03-26T17:15:36+00:00","article_modified_time":"2023-03-27T13:18:33+00:00","og_image":[{"width":221,"height":218,"url":"http:\/\/codermr.com\/wp-content\/uploads\/2023\/02\/xxl1.jpg","type":"image\/jpeg"}],"author":"\u7801\u5148\u751f","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/mrcode2021","twitter_site":"@mrcode2021","twitter_misc":{"\u4f5c\u8005":"\u7801\u5148\u751f","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/#article","isPartOf":{"@id":"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/"},"author":{"name":"\u7801\u5148\u751f","@id":"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf"},"headline":"xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3","datePublished":"2023-03-26T17:15:36+00:00","dateModified":"2023-03-27T13:18:33+00:00","mainEntityOfPage":{"@id":"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/"},"wordCount":74,"commentCount":0,"publisher":{"@id":"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf"},"keywords":["xxl-job"],"articleSection":["JAVA"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/","url":"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/","name":"xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3 - \u7801\u5148\u751f\u7684\u535a\u5ba2","isPartOf":{"@id":"http:\/\/codermr.com\/#website"},"datePublished":"2023-03-26T17:15:36+00:00","dateModified":"2023-03-27T13:18:33+00:00","breadcrumb":{"@id":"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/codermr.com\/index.php\/2023\/03\/27\/xxl-job3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/codermr.com\/"},{"@type":"ListItem","position":2,"name":"xxl-job\u539f\u7406\u8bb2\u89e3\uff08\u4e09\uff09\uff1a\u8c03\u5ea6\u4e2d\u5fc3"}]},{"@type":"WebSite","@id":"http:\/\/codermr.com\/#website","url":"http:\/\/codermr.com\/","name":"\u7801\u5148\u751f\u7684\u535a\u5ba2","description":"\u6b22 \u8fce \u4e0b \u8f7d \u6211 \u5f00 \u53d1 \u7684 \u5404 \u7aef \u8f6f \u4ef6 \u548c APP","publisher":{"@id":"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/codermr.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf","name":"\u7801\u5148\u751f","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"http:\/\/codermr.com\/#\/schema\/person\/image\/","url":"http:\/\/codermr.com\/wp-content\/uploads\/2023\/02\/wukong.jpg","contentUrl":"http:\/\/codermr.com\/wp-content\/uploads\/2023\/02\/wukong.jpg","width":400,"height":400,"caption":"\u7801\u5148\u751f"},"logo":{"@id":"http:\/\/codermr.com\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/codermr.com","https:\/\/twitter.com\/https:\/\/twitter.com\/mrcode2021"],"url":"http:\/\/codermr.com\/index.php\/author\/coderma\/"}]}},"_links":{"self":[{"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/posts\/902"}],"collection":[{"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/comments?post=902"}],"version-history":[{"count":8,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/posts\/902\/revisions"}],"predecessor-version":[{"id":930,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/posts\/902\/revisions\/930"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/media\/729"}],"wp:attachment":[{"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/media?parent=902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/categories?post=902"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/tags?post=902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}