使 EJB MessageDrivenBean 像 DefaultMessageListenerContainer(JMS、OpenMQ)一样工作
我使用 Spring DefaultMessageListenerContainer
在设置 MessageSelector 值时获得一些动态优势,因为我使用的是 Glassfish OpenMQ,它在这方面并不是那么先进。 让我们看一下 JMS 消息。侦听器发出特定故障,这意味着:x
秒后重试。它再次尝试失败:在 x*y
秒后重试,依此类推,时间呈指数增长。如果重试 z
后仍无法处理它,请将其视为有害 JMS 消息。
DefaultMessageListenerContainer dmlc;
dmlc.stop();
dmlc.setMessageSelector(String.format("retries < %d AND retryTime <= %d", z, System.currentTimeMillis()));
dmlc.start();
我对这个解决方案不太满意,特别是当 Spring 文档在这里提出警告时:-)。不过,目前来说,一切都满足我们的需求。
现在,我在不同的应用程序上有多个 EJB 消息使用者。其中一些需要messageSelector的这种动态变化。不幸的是,据我所知,EJB MDB 不支持这种动态“功能”。例如,请参阅此。
这是正确的吗? EJB 解决方案有解决方法吗?我将不胜感激任何帮助。
I am using the Spring DefaultMessageListenerContainer
to gain some dynamic benefits in setting the MessageSelector value since I am using the Glassfish OpenMQ which is not that advanced in that regards.
Let's have a JMS message. The listener issues a specific failure that means: retry after x
seconds. It tries again with failure: retry after x*y
seconds, and so on the time grows exponentially. If you cannot handle it after z
retries, consider it as a poison JMS message.
DefaultMessageListenerContainer dmlc;
dmlc.stop();
dmlc.setMessageSelector(String.format("retries < %d AND retryTime <= %d", z, System.currentTimeMillis()));
dmlc.start();
I am not that satisfied with this solution, especially, when the Spring docs raise warning here:-). However, for the moment things meet our needs.
Now, I have a number of EJBs message consumers on different applications. Some of them need such dynamic changes of the messageSelector. Unfortunately, and to-my-best-knowledge, EJB MDBs do not support such dynamic "features". For example, see this.
Is that correct? is there a workaround for an EJB solution? I would appreciate any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要实现消息选择器的动态更改,您需要直接在 JMS 中实现它,例如
此外,您需要将此代码放置在它自己执行的某个位置,也许在异步任务中?但你会重新发明轮子,因为 Spring DMLC 做得更好。
我不知道你为什么要这样做:
To achieve dynamic changes to the message selector, you'd need to implement it straight in JMS, e.g.
Additionally, you'd need to place this code some place it executes on its own, perhaps in an asynchronous task? But you'd be reinventing the wheel, as Spring DMLC does that better.
I don't know why you're doing this: