I'm consuming messages from an ActiveMQ Artemis topic using JMS. My consumers are connecting directly to the FQQN of their consumer queues. Like this:
jmsTemplate.setDefaultDestinationName("Transactions.Client1::ConsumerA");
And the configuration in the broker.xml
is:
<address-setting match="Transactions.*">
<auto-create-dead-letter-resources>true</auto-create-dead-letter-resources>
<dead-letter-address>Transactions.Retry</dead-letter-address>
</address-setting>
But then, the name of the DLQ will be DLQ.Transactions.Client1
, without the consumer name.
What I need is that each consumer has its own DLQ. Something like DLQ.Transactions.Client1.ConsumerA
. Is this possible?
EDIT:
When I say "consumer", it may (actually) be more like a "consumer group". For example, ConsumerA
and ConsumerB
are two totally different applications, with (possibly) multiple running instances and managed by its own team. That's why I want a different DLQ for each one.
It's not possible to configure the broker to auto-create a dead-letter queue whose name contains the name of the queue where the message was originally sent. As noted in the documentation, the dead-letter queue is named according to the address where the message was originally sent along with any configured prefix and/or suffix.
However, the message itself will have a property named _AMQ_ORIG_QUEUE
which will contain the name of the queue where the message was originally routed. This means you can use a consumer with a message selector (e.g. _AMQ_ORIG_QUEUE = 'ConsumerA'
) so that the consumer will only receive messages which were originally routed to a particular queue. This is functionally equivalent to having a dead-letter queue per-queue.
For what it's worth, what you're calling the "consumer name" isn't the name of the consumer at all, at least not from the broker's point of view. It's just the name of the queue.
Ultimately it's just not possible to configure a dead-letter queue per-queue. It's only possible to configure a dead-letter queue per address. This is true whether the resources are create manually (e.g. via broker.xml
) or automatically.