Remotely determined errors

When you send messages to a remote queue, even when the local queue manager has processed your MQI call without finding an error, other factors can influence how your message is handled by a remote queue manager. For example, the queue you are targeting may be full, or may not even exist. If your message has to be handled by other intermediate queue managers on the route to the target queue, any of these could find an error.

Problems delivering a message

When an MQPUT call fails, you have the choice of attempting to put the message on the queue again, returning it to the sender, or putting it on the dead-letter queue.

Each option has its own merits, but you may not want to retry putting a message if the reason that the MQPUT failed was because the destination queue was full. In this instance, putting it on the dead-letter queue allows you to deliver it to the correct destination queue later on.

Retry message delivery

Before the message is put on a dead-letter queue, a remote queue manager attempts to put the message on the queue again if the attributes MsgRetryCount and MsgRetryInterval have been set for the channel, or if there is a retry exit program for it to use (the name of which is held in the channel attribute MsgRetryExitId field).

If the MsgRetryExitId field is blank, the values in the attributes MsgRetryCount and MsgRetryInterval are used.

If the MsgRetryExitId field is not blank, the exit program of this name runs. For more information on using your own exit programs, see WebSphere MQ Intercommunication.

Return message to sender

You return a message to the sender by requesting a report message to be generated to include all of the original message. See Report messages for details on report message options.

Using the dead-letter (undelivered message) queue

When a queue manager cannot deliver a message, it attempts to put the message on its dead-letter queue. This queue should be defined when the queue manager is installed.

Your programs can use the dead-letter queue in the same way that the queue manager uses it. You can find the name of the dead-letter queue by opening the queue manager object (using the MQOPEN call) and inquiring about the DeadLetterQName attribute (using the MQINQ call).

When the queue manager puts a message on this queue, it adds a header to the message, the format of which is described by the dead-letter header (MQDLH) structure, in WebSphere MQ Application Programming Reference. This header includes the name of the target queue and the reason the message was put on the dead-letter queue. It must be removed and the problem must be resolved before the message is put on the intended queue. Also, the queue manager changes the Format field of the message descriptor (MQMD) to indicate that the message contains an MQDLH structure.

MQDLH structure

You are recommended to add an MQDLH structure to all messages that you put on the dead-letter queue; however, if you intend to use the dead-letter handler provided by certain WebSphere MQ products, you must add an MQDLH structure to your messages.

The addition of the header to a message may make the message too long for the dead-letter queue, so you should always make sure that your messages are shorter than the maximum size allowed for the dead-letter queue, by at least the value of the MQ_MSG_HEADER_LENGTH constant. The maximum size of messages allowed on a queue is determined by the value of the MaxMsgLength attribute of the queue. For the dead-letter queue, you should make sure that this attribute is set to the maximum allowed by the queue manager. If your application cannot deliver a message, and the message is too long to be put on the dead-letter queue, follow the advice given in the description of the MQDLH structure.

You need to ensure that the dead-letter queue is monitored, and that any messages arriving on it get processed. A dead-letter queue handler is provided by WebSphere MQ on all platforms except VSE/ESA. It runs as a batch utility and can be used to perform various actions on selected messages on the dead-letter queue. If you have a queue manager on one of the platforms that does not provide a dead-letter queue handler, you will need to provide your own. The program could be triggered, or run at regular intervals. For further details, see WebSphere MQ System Administration Guide for WebSphere MQ for AIX, HP-UX, Linux, OS/2, Solaris, and Windows systems; for WebSphere MQ for z/OS see WebSphere MQ for z/OS System Administration Guide; for other platforms, see the appropriate System Management Guide.

If data conversion is necessary, the queue manager converts the header information when you use the MQGMO_CONVERT option on the MQGET call. If the process putting the message is an MCA, the header is followed by all the text of the original message.

You should be aware that messages put on the dead-letter queue may be truncated if they are too long for this queue. A possible indication of this situation is the messages on the dead-letter queue being the same length as the value of the MaxMsgLength attribute of the queue.

Dead-letter queue processing

The rest of this chapter contains general-use programming interface information.

Dead-letter queue processing is dependent on local system requirements, but you should consider the following when you draw up the specification:

Your dead-letter queue application should do one or more of the following:

There are two ways that you deal with the messages you have recovered from the dead-letter queue:

  1. If the message is for a local queue, you should:
  2. If the message is for a remote queue, put the message on the queue.

For information on how undelivered messages are handled in a distributed queuing environment, see WebSphere MQ Intercommunication.



© IBM Corporation 1993, 2002. All Rights Reserved