Setup:
The setup basically works fine except as soon as I am adding a @JmsListener
that listens to the DLQ.
So I have multiple JmsListener
where one listens to a regular queue q1
. In case the action fails twice the message is moved to the assigned DLQ DLQ.q1
.
This works as long as at this point in time there is no active consumer for DLQ.q1
. The messages are stored in the DLQ.
As soon as the consumer (JmsListener
) for the DLQ.q1
is enabled, the dead letters from q1 do not appear in the DLQ and are also not consumed. The message, total added messages, and messages killed from the DLQ still show 0.
Consuming a message that was directly sent to the DLQ works either.
Can it be problematic when having an active listener on the DLQ? Is there anything special to take care of?
I think I can now answer my own question.
When having a @JmsListener
on DLQ.q1
, this queue is auto-created (if auto-create-queue setting is enabled in broker). This queue has address=name, so address=DLQ.q1;name=DLQ.q1
.
When there is no Listener and the DLQ is auto-created because of a dead letter message, the queue is created with address=DLA;name=DLQ.q1
To receive from the DLA.DLQ.q1
the JMS Listener has to be setup like this:
@JmsListener(destination = "DLA::DLQ.q1")