Using queue rules

This section describes some examples of the use of queue rules.

The first example shows a possible use of the message expired rule, putting a copy of the message onto a Dead Letter Queue. Both queues and messages can have an expiry interval set. If this interval is exceeded, the message is flagged as being expired. At this point the messageExpired() rule is called. On return from this rule, the expired message is deleted.

Thefirst example sends any expired messages to the queue manager's dead-letter queue, the name of which is defined by the constant MQe.DeadLetter_Queue_Name in the Java codebase and MQE_DEADLETTER_QUEUE_NAME in the C codebase. The queue manager rejects a put of a message that has previously been put onto another queue. This protects against a duplicate message being introduced into the MQe network. So, before moving the message to the dead-letter queue, the rule must set the resend flag. This is done by adding the Java MQe.Msg_Resend or C MQE_MSG_RESEND field to the message.

The message expiry time field must be deleted before moving the message to the dead-letter queue.

Parent topic: Queue rules