Failure to process a message

 

The listener port will retrieve the messages from the message queue and pass them to the MDB. If there is an error in processing a message then the MDB will rollback and the message listener port will return that message to the queue. Of course, once back on the queue this message will be picked up again by the listener port and a never ending cycle could occur.

There are some settings that can stop this occurring. On each listener port it is possible to configure the maximum retries setting. By default this setting is set to 0, which means if the processing of one message fails then the listener port will stop. This is good for stopping the message from getting stuck in a never ending loop but it means that all the other messages waiting on the queue will not get picked up.

It is possible to change the maximum retries to a higher number and then this might give the message a chance to succeed. For example, if the message was being used to update a database but access to the database timed out then retrying might eventually work.

Even changing the maximum retries to a higher number might still result in the listener port stopping.

There is a way to stop this behavior occurring and that is through the use of backout queues on WebSphere MQ. Within the configuration of a queue in WebSphere MQ, it is possible to set a backout queue and backout threshold. The backout threshold works in the same way as the listener ports maximum retries. It counts the number of attempts at delivering a message. Upon reaching the backout threshold number of retries, the message is taken from the queue and placed on the queue specified in the backout queue.

These settings for the queue can be set using the GUI as shown in Figure 15-13 or using the command line.

Figure 15-13 The backout queue settings for a message queue.

Make sure to set the Harden Get Backout field to Hardened so that an accurate count of message deliveries is kept.

This now means that the listener port stopping can be avoided by making the backout queue threshold lower than maximum retries. If the maximum retries is set to three on the listener port and the backout threshold set to two, then the message will only ever get delivered twice and so not trigger the setting on the listener port. The message will be placed in the backout queue and perhaps another part of the application can be used to handle the backout queue.

The failed message will be handled and the message listener can continue to run.

 Prev | Next

 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.