PubSub+ Message Handling Features: Dead Message Queues
Tags: fordevelopers
Published: 2021-08-19 16:52:57

---
title: PubSub+ Message Handling Features: Dead Message Queues
published: true
date: 2021-06-15 14:35:32 UTC
tags: ForDevelopers
canonical_url: https://solace.com/blog/pubsub-message-handling-features-dead-message-queues/
---

 ![](https://solace.com/wp-content/uploads/2021/06/solace-blog-featured-image_gravestone-green.jpg) 

In the first blog in this series, I explained the concept of [message expiry](https://solace.com/blog/pubsub-messaging-handling-features-message-expiry/), or message-TTL. Here I’ll look at dead message queues (DMQs), which assumes you have background knowledge on [Solace endpoints](https://solace.com/blog/queues-vs-topic-endpoints/) and [Solace persistent messaging](https://solace.com/blog/delivery-modes-direct-messaging-vs-persistent-messaging/).

## **What is a Dead Message Queue?**

A dead message queue, sometimes referred to as a dead letter queue, is an endpoint to store messages that have lost delivery eligibility in their original endpoint, and stores messages for special processing or delayed consumption.

You might be wondering how a message can lose delivery eligibility, especially when it is originally published as persistent. There are two ways messages can be deemed ineligible for delivery:

1. ** **** Message Expiry:** The [first post in this series](https://solace.com/blog/pubsub-messaging-handling-features-message-expiry/) goes into more detail on message expiry, but as a summary it is when a message is published to an endpoint with a timer, or time-to-live. When this timer expires, the message is removed from the original endpoint and can be deleted or can be moved to a DMQ.
2. **Poison Message:** The second reason a message can lose delivery eligibility is if it is redelivered from an endpoint to a consumer too many times. This scenario could occur when a consumer is unable to process a message and crashes before sending an [application acknowledgement](https://solace.com/blog/delivery-modes-direct-messaging-vs-persistent-messaging/). When that application reconnects to the endpoint, it will receive the same message and would be stuck in a loop. In this case, the message is referred to as a poison message. To ensure an application does not get stuck in this loop, an endpoint can be set to redeliver a message a maximum number of times with the setting ‘Maximum Redelivery Count’. Once exceeded, the message will be removed from the endpoint or can be moved to a DMQ.  
[![](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-01.png)](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-01.png)

## **How do I use a Dead Message Queue with Solace PubSub+ Event Broker?**

A DMQ on Solace PubSub+ Event Broker is configured as a normal queue and can be created in the same manner on the Queue page of PubSub+ Broker Manager.  
[![](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-02.png)](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-02.png)

Once created, the DMQ is configured on the original endpoint in the ‘DMQ Name’ field.  
[![](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-03.png)](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-03.png)

Note that messages will not be moved into a DMQ unless they are published with the flag ‘DMQ-Eligible’. Without this set, the messages will be deleted from the original queue when they lose delivery eligibility.

That is an important point that bears repeating: **_Messages must be DMQ-Eligible!  
[![](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-04-1024x376.png)](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-04.png)_**

** ** If you want messages that expire to go to a DMQ, you need:

- Queue with ‘Respect-TTL’ enabled, a DMQ configured, and optionally a ‘Maximum-TTL’ specified
- Published messages can have a ‘Message-TTL’ and must be ‘DMQ-Eligible’

[![](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-05.png)](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-05.png)

If you want messages that reach the maximum redelivery count to go to a DMQ, you need:

- Queue with ‘Maximum Redelivery Count’ set (Redeliver Forever disabled), and a DMQ configured
- Published messages must be ‘DMQ-Eligible’

[![](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-06-1024x336.png)](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-06.png)

When a message moves from an endpoint to its DMQ, the below highlighted statistics will reflect this.  
[![](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-07.png)](https://solace.com/wp-content/uploads/2021/06/dmq-post_pic-07.png)

## **Why would I use a DMQ?**

A DMQ is useful for special processing when messages are unable to be consumed on their original endpoint. This could be for expedited processing of orders, or the DMQ consumer may process the message in a different way than the original consumer.

Take for example an order management system that must process orders in a timely manner. For orders that are not processed in the desired amount of time, they could be expired to a dead message queue for expedited processing.

Another good example is error handling: a message that can’t be consumed from the original queue is moved to a DMQ to be inspected and processed.

## Conclusion

I hope I’ve helped you feel more comfortable with what DMQs are and how to use them. If you found this post useful, you might want to check out the [message properties section of our docs](https://docs.solace.com/Solace-JMS-API/Setting-Message-Properties.htm), and our [PubSub+ for Developers](https://www.solace.dev/) page for more information. If you have any questions about queues and topic endpoints, try posting them to the [Solace Developer Community](https://solace.community/)!

The post [PubSub+ Message Handling Features: Dead Message Queues](https://solace.com/blog/pubsub-message-handling-features-dead-message-queues/) appeared first on [Solace](https://solace.com).