如何使用同一触发器在quartz调度程序中调度多个作业?
我在我的春季项目中使用石英调度程序。我必须在计划每 15 分钟运行一次的作业之后运行一个作业吗?我无法同时运行此作业,因为这两个作业必须使用不同的协议访问相同的邮件帐户(一个用于发送:smtp,另一个用于接收:imap),这可能会导致问题。请尽快回复,因为这是紧急要求。
I am using quartz scheduler in my spring project. I have to run a job after another job which is scheduled to run in every 15 mins? I cant run this job concurrently as both of this jobs have to access same mail account using different protocols(one to send:smtp and other to receive: imap) and it may cause problems. Please reply quickly, as its an urgent requirement.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需编写一个包装作业类,在第一个作业之后启动第二个作业。如果有必要的话,您可以在将来重复使用单独的作业。
Just write a wrapper job class that launches second job after the first. You could then reuse separate jobs in the future if there will be any necessity.
您可以编写一个作业侦听器来识别第一个作业何时结束,并让它启动第二个作业。但 Mindas 首先建议的解决方案更简单 - 将您的两个作业包装在另一个作业实现中,这就是您实际安排的作业。
You could do something with writing a job listener to recognize when the first job ends, and have it start the second. But the solution first suggested by mindas is easier - wrap both your jobs in another Job implementation, which is the one you actually schedule.