简体   繁体   English

ActiveMQ Artemis JMS 共享订阅

[英]ActiveMQ Artemis JMS Shared Subscription

I have a single node ActiveMQ instance with two competing consumers connected to a topic.我有一个单节点 ActiveMQ 实例,其中两个竞争消费者连接到一个主题。 The topic subscription is shared as per JMS 2.0 specification.根据 JMS 2.0 规范共享主题订阅。 Shared subscription does guarantee that only either of the subscribers (using same subscription name) gets the message.共享订阅确实保证只有两个订阅者(使用相同的订阅名称)才能收到消息。 But what I noticed is that it does not guarantee that the second message is delivered only if the first one is acknowledged.但我注意到的是,它不能保证只有在第一条消息被确认时才会传递第二条消息。 In case if the first consumer takes time to acknowledge the message, the second message is delivered to the free consumer even before the acknowledgement of the first one is sent by the consumer to the broker.如果第一个消费者需要时间来确认消息,则即使在消费者将第一个消息的确认发送给代理之前,第二个消息也会传递给免费消费者。 Is this a standard behaviour?这是标准行为吗? And is there a way to stop the broker from delivering the second message before the acknowledgement of the first one?有没有办法阻止代理在确认第一条消息之前传递第二条消息?

ActiveMQ Artemis allows the exclusive queues . ActiveMQ Artemis 允许排他队列 They are special queues which route all messages to only one consumer at a time.它们是特殊的队列,一次只将所有消息路由到一个消费者。 Obviously exclusive queues have a draw back that you cannot scale out the consumers to improve consumption as only one consumer would technically be active.显然,独占队列有一个缺点,即您无法扩展消费者以改善消费,因为从技术上讲,只有一个消费者是活跃的。

However I would suggest to take a look at the message grouping to scale out your solution.但是,我建议查看消息分组以扩展您的解决方案。 Message groups are useful when you want all messages for a certain value of the property to be processed serially by the same consumer, without stopping the delivery of messages with different value of the property to other consumers.当您希望由同一消费者串行处理具有特定属性值的所有消息而不停止将具有不同属性值的消息传递给其他消费者时,消息组很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM