Search code examples
activemq-artemis

Simulating a Classic duplex transport with federation in Artemis?


I am trying to migrate from ActiveMQ Classic to ActiveMQ Artemis, and I have a duplex TCP connector set up in Classic.

I have tried to set up a federation configuration, and I see that multicast addresses are correctly relayed over. I do not see anycast addresses being sent a copy. I can see why this may be expected given the definition of anycast, but I want to be able to reproduce the same semantics as in Classic (where I had a Classic queue that forwarded all its messages over).

For more clarity, I have two brokers, A and B, and I have broker B (secondary) configured with an upstream of A, and a downstream to A with an upstream ref of B. I have an address policy of matching all addresses on this. Broker A has no federation config.

I am observing that multicast addresses created on A seem to be replicated on B, which shows that the upstream from B to A seems to work. But anycast (JMS queues created rather than topics) don’t seem to get created on B. I expect this to work like a duplex matching all queues/topics in Classic.

My expectation is that every message sent to broker A’s queue is received by someone subscribing to the same queue by name on broker B. In other words, I expect that by producing on A and consuming on B, I will get the same messages as if I were consuming on A. I effectively want any messages published on A to be relayed to B and vice versa for all addresses.

I see that the documentation states:

A federated address can replicate messages published from an upstream address to a local address. n.b. This is only supported with multicast addresses.


Solution

  • The documentation you cited is referring specifically to the ability of federation to replicate or copy messages sent to a multicast address on one broker to the same multicast address on other federated brokers. In this way you can get pub/sub (i.e. JMS topic) semantics across a whole network of federated brokers.

    This specific behavior doesn't work with anycast addresses because they adhere to point-to-point (i.e. JMS queue) semantics. All the consumers on a JMS queue share (i.e. compete for) the messages on that queue. To replicate or copy those messages to other federated nodes would break the basic delivery semantics.

    However, relaying or forwarding a message from one broker to another via federation will work for anycast addresses, but that's not the same as replicating or copying those messages. Forwarding of messages is based on consumer demand.

    Also, it's worth noting that JMS clients don't subscribe to a queue like they would with a topic. They simply create a consumer.