java Apache Camel-Quartz 集成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7728093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache Camel-Quartz Integration
提问by IAmYourFaja
I'm trying to use the camel-quartz
Camel component to schedule jobs on our application server (this technology selection is final and is above my paygrade), and the only documentation Apache provides (here) is de minimis and is ultra compacted without any real helpful examples for camel/quartz newbies.
我正在尝试使用camel-quartz
Camel 组件在我们的应用程序服务器上安排作业(此技术选择是最终的,并且高于我的薪水),并且 Apache 提供的唯一文档(此处)是最低限度的并且非常紧凑,没有任何真正有用的示例对于骆驼/石英新手。
I'm trying to understand the big picture here, before I can drill down into my specific jobs' needs. The documentation states that - via Camel - Quartz timers are set up as endpoints. So I'm assuming(please correct me if I'm wrong) that this means that you code up jobs to be ran, along with their config/properties files, and then set up a Quartz timer as a Camel endpoint; then when those jobs get ran, they somehow can communicate over Camel to other endpoints (?).
在深入了解我的特定工作的需求之前,我试图了解这里的大局。文档指出 - 通过 Camel - Quartz 计时器被设置为端点。所以我假设(如果我错了,请纠正我)这意味着您编写了要运行的作业及其配置/属性文件,然后将 Quartz 计时器设置为 Camel 端点;然后当这些作业运行时,它们可以以某种方式通过 Camel 与其他端点(?)进行通信。
So is that the only benefit to using camel-quartz
instead of just Quartz (that it allows your jobs to communicate with other endpoints)?
那么这是camel-quartz
不是使用Quartz的唯一好处(它允许您的作业与其他端点进行通信)?
Quartz can be configured with a quartz.properties
file, and requires other configuration to so that a Scheduler can be initialized. Does camel-quartz
take care of this for you?I'd like to just concentrate on writing the job, but not sure what sort of minimal XML or properties configurations are necessary.
Quartz 可以通过quartz.properties
文件进行配置,需要其他配置才能初始化 Scheduler。会camel-quartz
替你照顾这个吗?我只想专注于编写工作,但不确定需要什么样的最小 XML 或属性配置。
Thanks in advance to anyone who can help clarify this camel-quartz
development process a little better.
在此先感谢任何可以帮助camel-quartz
更好地阐明此开发过程的人。
采纳答案by Christian Schneider
Have you already seen the camel-quartz documentation on the camel website? http://camel.apache.org/quartz.html
你已经看过camel网站上的camel-quartz文档了吗? http://camel.apache.org/quartz.html
It is not very detailed but should get you started. The quartz.properties is searched at the base of the class path. You can also specify another file or use custom Properties. See the "Configuring quartz.properties file" section.
它不是很详细,但应该可以帮助您入门。在类路径的基部搜索quartz.properties。您还可以指定另一个文件或使用自定义属性。请参阅“配置quartz.properties 文件”部分。
Camel-quartz has the simple purpose of triggering a camel route. So you can use all the other camel components to implement your requirements. If your job is about integration then camel-quartz is a good choice. If your job mainly calls internal APIs of your app then the normal quartz should be good enough.
骆驼石英具有触发骆驼路线的简单目的。因此,您可以使用所有其他骆驼组件来实现您的需求。如果您的工作是关于集成,那么骆驼石英是一个不错的选择。如果您的工作主要调用应用程序的内部 API,那么普通的quartz 就足够了。
回答by Sunil Manheri
Setting up a quartz end point is easy, the below quartz job triggers FileProcessor.process() at 1AM every day:
设置石英端点很容易,下面的石英作业在每天凌晨 1 点触发 FileProcessor.process():
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<package>com.test.app</package>
<template id="camelTemplate"/>
<route>
<from uri="quartz://fileProcessorJob?cron=0+0+1+*+*+?"/>
<to uri="bean:fileProcessor?method=process"/>
</route>
</camelContext>
By default Quartz looks for quartz.properties in the class path, you can also provide the configuration details in the xml as shown below:
Quartz默认在类路径中寻找quartz.properties,你也可以在xml中提供配置细节,如下图:
<bean id="quartz" class="org.apache.camel.component.quartz.QuartzComponent">
<property name="propertiesFile" value="com/test/app/myquartz.properties"/>
</bean>