关联 JMS 消息的计划重试
我有一个单线程消息侦听器,用于侦听传入消息。接收到的消息在收到时保留在数据库中。
有一条消息 A,关联的消息 B 跟随它并引用它。在某些奇怪的情况下,B 在 A 之前到达。现在在这种情况下,在一些“x”相等的间隔之后必须有 3 次重试,以查看 A 是否已到达并且然后保持关联。
由于消息监听器是单线程的,如果我们让线程休眠,整个系统都会受到影响。所以必须有一个单独的线程重试。
我们是否可以使用 Quartz Job Scheduler 来实现此目的,以避免处理多线程问题,并通过以下 2 种方式中的任何一种来持久存储,
- 在 Quartz 中调度作业 3 次,并跟踪 JobDataMap 中的标志以检查是否之前的重试成功,然后返回而不执行任何操作
,或者
2.安排一个作业重试一次,然后如果重试失败,则在几秒钟后安排相同的作业。
石英是否只能用于重复性工作,并且没有跨工作的一些状态信息,或者是否有其他更好的方法来做到这一点。
I have a single threaded message listener that listens for the incoming messages.The received messages are persisted in a database as they are recieved.
There is a message A and associated message B follows it with a reference it.In Some Odd occurences, B arrives before A. Now in this case, There has to be 3retries after some 'x' equal intervals to see if A has arrived and then persists the association.
As the message listener is single threaded if we put the thread to sleep the whole system would be affected. So there has to be a separate thread retrying.
Can we use Quartz Job Scheduler for this purpose to avoid handling multiThreading issues and to have a PERSISTENT STORE of the in any of the following 2 ways,
- Schedule a Job in Quartz for 3 times and keep track of a flag in the JobDataMap to check if previous retries succeeds then return without doing anything
OR
2.Schedule a Job to retry once and then if the retry fails schedule the same job after a few seconds.
Can quartz be used only for repetitive jobs and not have some state information span across job or Is there any other better way to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该配置 JMS 提供程序以设置消息队列上的重新传递延迟。在您的代码中,您可以调用
context.setRollbackOnly
来中止未通过先决条件检查的消息。这样的话,代码执行场景就变成:
You should configure your JMS provider to set the redelivery delay on your message queue. In your code, you call
context.setRollbackOnly
to abort a message that does not pass prerequisites check.In that case, the code execution scenario becomes: