Technology

The end of poison messages | Detection and Solutions

poison message

What are poison messages?

Poison messages are messages that have exceeded the maximum number of delivery attempts to the application – that max number, however, is variable. Such a situation arises when a queue-based application cannot process a message due to errors. 

poison message

 

End of Poison Messages

It is difficult to know whether the failure is permanent or transient.

Thus it is recommended to retry the failed message, however, not ad infinitum. If retries do not work after a couple of attempts, action is required. Such actions could range from the message being moved to a ‘poison messages’ queue, a notification sent to an admin, etc. 

We will discuss how to handle poison messages later, but our first challenge is to know/regulate when a message should not be tired anymore. 

Time to Be Received Message 

In MSMQ, every message has a ‘TimeToBeReceived’ property. 

The default setting is set with InfiniteTimeout, but a sender can change this to something else entirely. For instance, a sender can set it up to 5 minutes in the future. The best part of this property is when that time limit ends/expires, the Message Queuing will automatically take care of such a message – either by deleting it or moving it to a dead letter queue. 

Which of these two scenarios takes precedence will depend on the UseDeadLetterQueue attribute. 

Expanding on MSMQ, let’s look into ways to end of poison messages

Handling the End of Poison Messages

After covering general aspects of poison messages and their detection, let’s ponder;

Are there ways to improve performance and robustness?

What to do when a message should not be tried anymore? 

Delete it? 

Or 

Take it someplace else? 

For MSMQ, the below-mentioned approaches will kick in when a message fails. You might need to integrate/use third-party tools or write utilities yourself to either move or delete messages. 

We will discuss simpler approaches;

Getting Rid of Poison Messages

If you are prioritizing message processing, and it is not important for you to be losing some messages – then drop the poison message and move on. 

But most people do not use MSMQ in this way. 

Roll Back

Want to preserve the messages?

The most straightforward message preserving solution is to roll back – this way, the poison message shall return to the top of the queue and stay there – and this could be forever. 

This solution is the simplest one, and there come no risks of losing a message. 

But now, it is for the administrator to fix the problem – as no other messages will be processed in the meantime. 

This method is workable if you want to process every message – and do not care when it is done. Plus, this solution also maintains the ordering of messages. 

Moving to Dead-Letter Queue | Retrying 

This is an extension of the previous solution. 

poison message
When a message fails several times, move it to the dead-letter queue. You can move all poison messages to the system dead-letter queue or create a separate dead-letter queue for every queue. 

The downside to this? 

Suppose you face some temporary issue – like the connection to an external resource being down. This will put perfectly valid messages in the dead-letter queue, and these messages cannot be sent to the original queue except when the administrator does so manually. 

Thus, this solution needs constant monitoring and manual interventions. 

Read more:- Best Top Tranny Tube Shemale Tube

Send Messages Back

Problem with previous solutions is that the failed messages go back to the top of the queue, effectively hindering other messages from being processed. 

What happens if you move it to the bottom of the queue after failure? – The other messages will get processed. 

However, as rollback sends the message back to the queue top, we can’t use it. Still, if we finish receiving the operation, it will remove the message from the top of the queue and send it again, putting it to the bottom now. It will help to have Receive and Send messages in one transaction. 

Tip: Reduce the priority of poison messages to the lowest when being sent back to the queue.

Retry queue

All solutions have so far blocked the main queue – at least temporarily. 

If that’s a bone to pick with, use another queue for retrying, immediately moving all failed messages there. Thusly, the main queue will never get blocked. Now, you need a separate receiver for the entry queue – which shall pose delays; however, the valid messages will get processed instantly. 

Too technical? 

Head over to Memphis{dev} – a full-scale message broker service for developers. Get a faster, better, and less invasive message broker NOW!

To Top

Pin It on Pinterest

Share This