在 JMS 队列中实现 ActiveMQ 的粘性会话(消息组)
我正在尝试放弃 ActiveMQ,但我们想要保留的一项功能是消息组。通过将会话 ID 添加到 JMS 标头,ActiveMQ 会将队列上具有相同 ID 的所有其他消息路由到同一消费者(我们的消费者可能位于不同的机器上),从而允许接收者将一组消息视为一个工作单元。
我的第一个想法只是将会话置于 CLIENT_ACKNOWLEDGE 模式。我的想法是,如果消费者 A 查看标头并发现它不是它正在处理的 ID,那么它可以直接删除该消息,而消费者 B 会拾取该消息。我遇到了几个问题,包括 ActiveMQ 的完善,而且我读得越多,就越觉得这不是最初设计的目的。
我能想到的一个想法是建立一个调度队列,然后将消息路由到每个消费者的(由于缺乏更好的词,子队列)并自行管理将会话 ID 与子队列匹配。
在我走这条路之前,我们对此持怀疑态度,因为它会增加代码的复杂性,然后我们想要,关于 CLIENT_ACKNOWLEDGE 是否有我遗漏的东西?或者我应该先尝试其他什么?
I'm trying to move off of ActiveMQ but one feature we'd like to keep is the message group. By adding a session ID to the JMS header ActiveMQ will route all other messages on the queue with the same ID to the same consumer (our consumers may be on different machines) allowing the receiver to treat the group of messages as one unit of work.
My first thought was simply to put the session into CLIENT_ACKNOWLEDGE mode. My thinking was that if consumer A looked at the header and saw it wasn't an ID it was handling then it could just drop the message and consumer B would pick it up. I've hit several issues, including ActiveMQ's prefecting, and the more I read, the more it looks like that's not what that was designed for to begin with.
The one idea I can think of is to have a dispatch queue which would then route messages to each consumer's, for lack of a better word, sub-queue and manage matching the session IDs to the sub-queues ourselves.
Before I head down this path, which we're leery of since it'd add more complexity to the code then we'd like, is there anything I'm missing about CLIENT_ACKNOWLEDGE? Or something else entirely I should try first?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是您想要做的http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/5/html-single/HornetQ_User_Guide/index.html#message-grouping
Is this what you are trying to do http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/5/html-single/HornetQ_User_Guide/index.html#message-grouping