Configuring Dead Message Queues
You can create a dead message queue (DMQ) to receive messages that are discarded from one or more queues or topic endpoints when they can't be delivered to the subscribing client. By default, messages are discarded from an endpoint in the following circumstances:
-
the maximum time-to-live (TTL) value for the message has been reached and the endpoint is configured to respect message TTL expiry times.
-
the number of redelivery attempts to the consumer for a message has reached the max redelivery count value for the original endpoint.
Discarded messages are deleted unless a DMQ is configured to receive messages discarded by the queue or topic endpoint and the message is flagged as DMQ-eligible by the publisher.
Solace recommends that you use a separate DMQ for each queue and topic endpoint that needs one. Separate DMQs make it easier to manage dead messages from multiple queues and makes investigating DMQ messages easier.
For more information about DMQs, see Dead Message Queues.
Considerations for DMQs
For a message to be moved to a DMQ instead of being discarded, all of the following conditions must be met:
-
The DMQ must exist on the same event broker service. You must create a DMQ with the name specified in the original endpoint. If the DMQ doesn't exist, discarded messages are deleted, even if they are DMQ-eligible.
-
To discard messages based on a TTL, the queue must respect TTL values. If the queue doesn't respect TTLs, messages do not expire and are not discarded from the queue. You can configure a maximum TTL value on the queue, which begins when a message arrives on the queue. Publishing clients can also set a TTL for messages, which begins when the message is published. If the queue respects TTL values, messages are discarded when the earliest TTL is reached.
-
To discard messages based on the number of maximum number of redelivery attempts to the consumer was reached, the maximum redeliver count must be configured. For more information, see Configuring Message Delivery Options.
- The publishing client must designate messages as DMQ-eligible. For developer information:
- on Solace messaging APIs, see Dead Message Queue Eligibility.
- on Solace REST messaging, see Solace-Specific HTTP Headers .
- on JMS APIs, see Dead Message Queue Eligibility.
- for AMQP 1.0, every message is DMQ-eligible.
Configuring a DMQ
Configuring DMQs includes two tasks:
-
Create one or more queues to function as a DMQ for other queues and topic endpoints on the same event broker service. Solace ©recommends creating a separate DMQ for each queue and topic endpoint that needs one and naming the DMQ
<endpoint-name>_dmq
. For more information, see Creating a Queue. -
Configure settings in another endpoint to discard messages that have not been delivered and send the messages to a specified DMQ. For more information, see Sending Messages to a DMQ.
The endpoint settings to enable sending discarded messages to a DMQ depend on the reason for discarding the message:
-
Respect TTL must be selected to send messages to a DMQ based on a maximum TTL value.
-
Maximum TTL values can be set for the queue or topic endpoint, by the message publisher, or both:
-
If you want to remove all messages from a queue or topic endpoint if they remain undelivered for a specified time period, set the maximum TTL for the endpoint.
-
If you only want to respect TTL values set by a message publisher that wants messages to expire, you don't need to set a maximum TTL for the endpoint.
-
If a message has both a TTL set by the publisher and a maximum TTL set by the endpoint, the message is removed from the endpoint when the earliest TTL is reached. For example, if the message has a TTL of 90 seconds after it was published and a queue has a TTL of 60 seconds after the message arrives in the queue, the message is sent to the DMQ when the first TTL expires.
-
-
If you want messages to be removed from an endpoint after a specified number of redelivery attempts, set a maximum redelivery count for the endpoint.
Sending Messages to a DMQ
For more information about message delivery settings in a queue, see Configuring Message Delivery Options.
To configure an endpoint to send messages to a DMQ in Broker Manager, perform these steps:
- Open Broker Manager. For instructions, see Using PubSub+ Broker Manager.
- Select Queues in the left navigation bar.
- Select the Queues or Topic Endpoints tab.
- Select the endpoint that you want to configure a DMQ for. If it doesn’t exist yet, see Configuring Queues or Configuring Topic Endpoints.
- Click Edit
.
- Click Show Advanced Settings.
- In the DMQ Name field, enter a name of another queue on your event broker service. The default name is
#DEAD_MSG_QUEUE
, however, Solace recommends using a separate DMQ for each endpoint that requires one and naming the DMQ<endpoint-name>_dmq
, for example:MyQueue_dmq
. If you use the default name, or enter a name for a queue that doesn't exist, you must create it. - In the Message Expiry section, click the Respect TTL
toggle to enable it.
- (Optional) Set a value in the Maximum TTL (sec) field. A value of 0 for the Maximum TTL means that the endpoint does not impose a maximum TTL but respects a TTL set by the publisher.
- (Optional) To set a limit on the number of redelivery attempts before a message is sent to the DMQ, click the Try Forever
toggle to disable it and then set the Maximum Redelivery Count value and any other redelivery options you require. For more information, see Configuring Message Delivery Options.
- Click Apply.
After you have configured a DMQ for your queue in Broker Manager, messages that are DMQ-eligible are sent to the configured DMQ when the Maximum TTL value or maximum redelivery count is exceeded. Messages in the DMQ keep their original headers, including the endpoint to which they were originally bound, so you can investigate them when necessary.