简体   繁体   English

ActiveMQ:消费者一旦被选择处理特定的消息组,就不会收到非分组的消息

[英]ActiveMQ: consumer not getting non-grouped messages once it is selected to handle a specific message group

We're using ActiveMQ (5.14.5).我们正在使用 ActiveMQ (5.14.5)。 We have a single producer, and multiple consumers on the same queue.我们有一个生产者,在同一个队列中有多个消费者。 From time to time we set JMSXGroupID to group several messages together to be consumed on a single consumer.我们有时会设置 JMSXGroupID 来将多个消息组合在一起,以便在单个消费者上使用。 This works as expected.这按预期工作。 In parallel, the producer continues to send non-grouped messages (ie without JMSXGroupID)同时,生产者继续发送非分组消息(即没有 JMSXGroupID)

The problem: We noticed that once a consumer was selected to process a specific group, it no longer gets the non-grouped messages.问题:我们注意到,一旦选择了一个消费者来处理特定的组,它就不再获得非分组的消息。 Even if it is completely idle.即使它完全闲置。 The non-grouped messages are always sent to the other consumers.未分组的消息总是发送给其他消费者。 The rogue consumer returns to consume non-grouped messages only after we close the group that was assigned to it (by setting JMSXGroupSeq=-1).只有在我们关闭分配给它的组(通过设置 JMSXGroupSeq=-1)后,流氓消费者才会返回使用未分组的消息。

Is this a normal behavior?这是正常行为吗? We expected that non-grouped messages will continue to be delivered in the same round-robin fashion as usual, to all consumers.我们预计非分组消息将继续以与往常相同的循环方式传递给所有消费者。 We were unable to find a clear reference to this in ActiveMQ documentation.我们无法在 ActiveMQ 文档中找到对此的明确引用。

There's a bit of a no-win situation for the message broker here.对于消息代理来说,这里有一些双赢的局面。 If there are active message groups in play, the the broker has to assume that further messages will be produced that fall into those groups.如果有活动的消息组在起作用,则代理必须假设将生成更多属于这些组的消息。 So a message consumer that has become bound to a particular group needs to remain available to consumer later messages of that group, rather than ungrouped messages.因此,已绑定到特定组的消息消费者需要对该组的消费者后续消息保持可用,而不是未分组的消息。 After all, an ungrouped message can be handled elsewhere, while a grouped message can't.毕竟,未分组的消息可以在其他地方处理,而分组的消息则不能。

However, we also want to have a fair-ish distribution of messages between consumers.但是,我们也希望在消费者之间公平地分配消息。 So it makes sense that a consumer that is bound to a group, or groups, could take some work when it is idle.因此,绑定到一个或多个组的消费者在空闲时可以做一些工作是有道理的。

But how do we know it is idle?但是我们怎么知道它是空闲的呢? What happens if a consumer takes a bunch of ungrouped messages (and don't forget the default pre-fetch behaviour), and then new messages arrive that match its specific group?如果消费者接受一堆未分组的消息(并且不要忘记默认的预取行为),然后新消息到达匹配其特定组,会发生什么?

The fact that closing a group restores the "group consumer" to default behaviour suggests to me that this is not a bug, but a deliberate attempt to make a reasonable compromise in a tricky situation.关闭群组会将“群组消费者”恢复为默认行为这一事实向我表明,这不是错误,而是在棘手情况下故意做出合理妥协的尝试。 It seems reasonable to me to ask for a feature to be added, where "group consumers" can take part in ungrouped workload, but I would be inclined to see that as an enhancement.对我来说,要求添加一项功能似乎是合理的,其中“组消费者”可以参与未分组的工作负载,但我倾向于将其视为增强功能。

Just my $0.02, of course.当然只是我的 0.02 美元。

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

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