Handling poison messages
Despite taking all the care to write bug-free code, there are always circumstances that can cause the processing of a message to fail. The cause of the failure could be due to an error in the code which causes the server to throw an exception. Message processing could also fail due to a configuration issue, or reliance on an external resource which is unavailable at that moment.
In the event of a failure, the message will not be deleted from the queue as the application logic was not able to get that far. As the message was not deleted, it will eventually become visible again, and dequeued by another consumer which will attempt to process the message. If the cause of the failure was an intermittent one, then the message will be processed fine at a later time when retried. However, the issue may be persistent if it is an error with the message payload, the application code, or the configuration. These messages will be continuously dequeued, then processed by an instance...