spring - 配置 Quartz2 apache Camel 和 Fuse
问题描述
我在骆驼中有下一部分代码
<route id="ROUTE-WK-OPSWEBGUSOXUA" streamCache="true">
<from id="_from1" uri="{{opsweb.gusoxUA.timer.Endpoint}}?cron={{opsweb.gusoxUA.cron.timer}}&stateful=true">
<description>Principal Route of wk-opswebGusoxUA</description>
</from>
<bean id="_bean1" method="queryOpsweb" ref="jdbcTemplateOpsweb">
<description>query pesobalance.soc_users_opsweb where user_state = 'A'</description>
</bean>
<doTry id="_doTry1">
<choice id="_choice1">
<when id="_when1">
<simple>${body} == '[]'</simple>
<log id="_log2" loggerRef="loggerRef"
loggingLevel="INFO" message="Result query dbo.sistemas empty => ${body} "/>
<!-- Lanzar una Excepcion -->
</when>
<otherwise id="_otherwise1">
<log id="_log3" loggerRef="loggerRef"
loggingLevel="INFO" message="Empieza Splitter "/>
<split id="_split1" stopOnException="false">
<simple>${body}</simple>
<process id="_process2" ref="csvTrasformationProcessor"/>
<log id="_log6" loggerRef="loggerRef"
loggingLevel="INFO" message="Register of ApplicationAfter => ${body}"/>
<marshal id="_marshall1" ref="dataModel"/>
<to id="_to2" uri="file:{{opsweb.gusoxUA.file.location}}?fileName=${date:now:yyyyMMdd}_opsweb.csv&fileExist=Append"/>
</split>
但是石英创建了 10 个线程并执行了 10 次,而我只想执行 1 次。
当我在保险丝中部署它时,我看到了下一个:
2020-04-21 14:58:50,081 | INFO | xtenderThread-46 | ManagedManagementStrategy | 172 - org.apache.camel.camel-core - 2.15.1.redhat-621084 | JMX is enabled
2020-04-21 14:58:50,112 | INFO | xtenderThread-46 | QuartzComponent | 222 - org.apache.camel.camel-quartz2 - 2.15.1.redhat-621084 | Create and initializing scheduler.
2020-04-21 14:58:50,113 | INFO | xtenderThread-46 | QuartzComponent | 222 - org.apache.camel.camel-quartz2 - 2.15.1.redhat-621084 | Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX.
2020-04-21 14:58:50,114 | INFO | xtenderThread-46 | StdSchedulerFactory | 272 - org.quartz-scheduler.quartz - 2.2.1 | Using default implementation for ThreadExecutor
2020-04-21 14:58:50,114 | INFO | xtenderThread-46 | SimpleThreadPool | 272 - org.quartz-scheduler.quartz - 2.2.1 | Job execution threads will use class loader of thread: SpringOsgiExtenderThread-46
2020-04-21 14:58:50,115 | INFO | xtenderThread-46 | SchedulerSignalerImpl | 272 - org.quartz-scheduler.quartz - 2.2.1 | Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
2020-04-21 14:58:50,115 | INFO | xtenderThread-46 | QuartzScheduler | 272 - org.quartz-scheduler.quartz - 2.2.1 | Quartz Scheduler v.2.2.1 created.
2020-04-21 14:58:50,115 | INFO | xtenderThread-46 | RAMJobStore | 272 - org.quartz-scheduler.quartz - 2.2.1 | RAMJobStore initialized.
2020-04-21 14:58:50,116 | INFO | xtenderThread-46 | QuartzScheduler | 272 - org.quartz-scheduler.quartz - 2.2.1 | Scheduler meta-data: Quartz Scheduler (v2.2.1) 'DefaultQuartzScheduler-com.avianca.datacenter.sal.WK-opswebGusoxUA' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
我如何将 Quartz 配置为仅执行一次而不是 10。
解决方案
如果只想执行一次,则 timer 更适合 repeatCount=1:
timer://timerName?repeatCount=1
如果是每 XX 秒一次,请使用石英:
每 60 秒。
quartz2://timerName?cron=0 0/1 * 1/1 * ? *
取决于 {{opsweb.gusoxUA.cron.timer}} 的内容
推荐阅读
- c# - 如何在reactjs中的C#中将查询结果的值存储在2个不同的变量中
- reactjs - 如何在 pdf 中转换文件并在 react native 中下载
- security - 有没有办法使用 GraphQL 从 GitHub 安全公告数据库中提取特定存储库的安全公告?
- jenkins - 在 Jenkins 的框中将活动的选定参数显示为逗号分隔值
- javascript - 为什么特定的 cookie 总是返回 undefined?
- python - 打开 chrome webdriver 后 Python 脚本崩溃
- c# - 元组
与 GroupBy - reactjs - 处理多个 useEffect 挂钩
- python - python中的正则表达式负前瞻
- typescript - 类型 SomeType[number] 不能分配给 SomeType[number] ...嗯?