ActiveMQ Message Groups Support

115 views
Skip to first unread message

James

unread,
Aug 19, 2019, 9:43:43 PM8/19/19
to masstransit-discuss
I am running ActiveMQ 5.15.8 and would like to use the Message Groups functionality provided by the broker: https://activemq.apache.org/message-groups

I have attempted to accomplish this by setting a header value in the publish/send context but when I have multiple consumers they still behave as competing consumers. For example in the sample below, I would have expected that all my messages would be sent to a single consumer elected by ActiveMQ.

_bus.Publish<ISampleEvent>(new { Message = "Hello World" }, ctx =>
{
    ctx
.Headers.Set("JMSXGroupID", "A");
});

Chris Patterson

unread,
Aug 20, 2019, 8:55:42 AM8/20/19
to masstrans...@googlegroups.com
From reading the link you sent, it seems like this is automatically performed by the broker when multiple consumers are on the same queue, using the transport header to dispatch messages with the same GroupID to the same consumer. If you can confirm the header is indeed being set on the message when it is delivered to the queue, it seems like something inside ActiveMQ that would take it from that point.

If the transport header isn't present on messages in the queue, then something else is wrong.

It also might be useful to try sending to a queue directly (using GetSendEndpoint(address), followed by Send(...)), instead of using publish, to see if the header is being lost due to the publish/subscribe semantics of how ActiveMQ is used in that scenario. I don't think that should matter, but only mentioning it since sometimes brokers do different things depending upon the message delivery semantics.



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/9581aee4-e398-4fd4-9d81-4cec35976562%40googlegroups.com.

James

unread,
Aug 21, 2019, 1:24:48 AM8/21/19
to masstransit-discuss
It's taken me 2 days of trying different approaches, but I have solved the problem.

MassTransit uses the NMS API, so the header key to enable Message Groups is NMSXGroupID rather than JMSXGroupID.

Appreciate the help.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Chris Patterson

unread,
Aug 21, 2019, 1:35:57 PM8/21/19
to masstrans...@googlegroups.com
Ah, great. Glad you found it.


To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/d13d5803-dbd0-49eb-a93f-4b7958fb8ab2%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages