使用 Quartz 的动态作业数据
当我的进程收到消息时,它需要启动一个计时器并在 X 秒内执行一些逻辑。这些作业需要存储在 JDBC 存储中,据我所知,这可能与这个问题无关。
根据我所读到的内容,我应该能够将具有相似属性的不同值的 JobDataMap 分配给单个 Job 类,但我无法找到任何文档或示例来支持此用例。也许我的谷歌能力很弱。
这有道理吗?有一个 Job 类并以某种方式存储 JobDataMap 来填充该 Job 类并在每条消息的基础上运行它?
When my process gets a message, it needs to start a timer and execute some logic in X seconds. These jobs need to be stored in a JDBC store, which as far as I can tell may be irrelevant to this question.
Based on what I've read, I should be able to assign a JobDataMap with different values for similar properties to a single Job class, but I'm unable to find any documentation or examples to back this use-case. Perhaps my Google-fu is weak.
Does that make sense? Have one Job class and somehow store a JobDataMap to populate that Job class and run it on a per-message basis?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
org.quartz.Trigger
既有getJobDataMap()
(如有必要,它会new
)和setJobDataMap()
> 获取触发器的 JobDataMap 。最简单的用法是:
使用现有的值映射进行初始化:
在作业执行时获取数据
教程中有关 JobDataMap 的文档。
org.quartz.Trigger
has bothgetJobDataMap()
(which willnew
up one if necessary) andsetJobDataMap()
to get the trigger's JobDataMap.The simplest usage would be:
To init with an existing Map of values:
To get the data when your job executes
Documentation on JobDataMap in the tutorial.
嗨cansando(你说西班牙语???)。
我将以 Quartz 为例。
在此行中 SimpleTrigger trigger2 = new SimpleTrigger("lanzadorprincipal", "lanzadores", "instruccion","instrucciones" , Calendar.getInstance().getTime(), null, 100, 10000);
您可以设置执行和重复的时间吗?
Hi cansando (you speak spanish???).
I going to give you my example of Quartz.
In this line SimpleTrigger trigger2 = new SimpleTrigger("lanzador principal", "lanzadores", "instruccion","instrucciones" , Calendar.getInstance().getTime(), null, 100, 10000);
can you set the time to execute and repeat.