1
votes

I'm trying to understand how Artemis does its routing (I'm using Artemis 2.11.0). I would like to configure two different addresses STATUS_LOG.V01 and STATUS_LOG.V02. From a JMS perspective one is a queue (V01) and one is a topic (V02). The topic should multicast its messages to the previously defined queue. I have the following in broker.xml:

<address name="STATUS_LOG.V01">
   <anycast>
      <queue name="STATUS_LOG.V01" />
   </anycast>
</address>
<address name="STATUS_LOG.V02">
   <multicast>
      <queue name="STATUS_LOG.V01" />
   </multicast>
</address>  

When I send a message to the STATUS_LOG.V01 address I see it in the STATUS_LOG.V01 queue through the web UI as expected. When I publish a message to the STATUS_LOG.V02 address I expect to see the message in the STATUS_LOG.V01 queue, but I don't.

We have an existing queue which receives status messages (STATUS_LOG.V01) from endpoint adapters. Ultimately, we would like to add another destination (STATUS_LOG.V02) (a topic destination - PUBSUB behavior) to be used for future releases. However, we want the messages received on the new topic to be routed to the existing queue. Is this doable in ActiveMQ Artemis?

1
Through the web UItechathon
I'm trying to funnel one address to another (hence statically specifying the name).techathon
Thanks Justin. That clarifies it. We have an existing queue which receives status messages (STATUS_LOG.V01) from endpoint adapters. We would like to add another destination (STATUS_LOG.V02) (a topic destination- PUBSUB behavior) to be used for future releases. However, we want the messages received on the new topic to be routed to the existing queue. Is this doable in Artemis?techathon
I update your question with this important use-case description, and I also updated my answer as well.Justin Bertram
Thank you Justin for the clarification and the solution. I appreciate it.techathon

1 Answers

2
votes

What you're seeing is the expected behavior since your configuration is not allowed. Queue names must be unique across the broker. You can't have the same queue bound to multiple addresses. You are trying to configure the queue STATUS_LOG.V01 on both addresses STATUS_LOG.V01 & STATUS_LOG.V02. When you start the broker you should see logging like this:

INFO  [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address STATUS_LOG.V01 supporting [ANYCAST]
INFO  [org.apache.activemq.artemis.core.server] AMQ221003: Deploying ANYCAST queue STATUS_LOG.V01 on address STATUS_LOG.V01
INFO  [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address STATUS_LOG.V02 supporting [MULTICAST]
INFO  [org.apache.activemq.artemis.core.server] AMQ221003: Deploying MULTICAST queue STATUS_LOG.V01 on address STATUS_LOG.V02
WARN  [org.apache.activemq.artemis.core.server] AMQ229019: Queue STATUS_LOG.V01 already exists on address STATUS_LOG.V01

Notice the last WARN logged. This indicates that the queue STATUS_LOG.V01 cannot be bound to address STATUS_LOG.V02 since it is already bound on address STATUS_LOG.V01.

What you really need to do is create a divert to take messages sent to your STATUS_LOG.V02 address and forward them to your STATUS_LOG.V01 address. Use this instead of your original configuration:

<address name="STATUS_LOG.V01">
   <anycast>
      <queue name="STATUS_LOG.V01" />
   </anycast>
</address>
<address name="STATUS_LOG.V02">
   <multicast/>
</address> 
<divert name="myDivert">
   <address>STATUS_LOG.V02</address>
   <forwarding-address>STATUS_LOG.V01</forwarding-address>
   <exclusive>true</exclusive>
</divert>

It's not clear to me whether or not you'll want to set exclusive to true for your use-case or not. If exclusive is true then none of the JMS topic subscribers on STATUS_LOG.V02 will get the messages sent to STATUS_LOG.V02. All the messages sent to STATUS_LOG.V02 will be diverted exclusively to STATUS_LOG.V01. If exclusive is false then the JMS topic subscribers on STATUS_LOG.V02 will get messages sent to STATUS_LOG.V02 and the messages will also be diverted to STATUS_LOG.V01. You can read more about diverts in the documentation.