A JMS message is typically redelivered because of an error in the processing of the message. The error may be transient or permanent.
If the error is transient, the message will eventually go through. If the error is permanent, moving messages to a different destination may be a better approach. If the message is not valuable, deleting the message is another option.
Delaying delivery of a redelivered message is useful to save CPU cycles instead of letting the message "spin" rapidly.
You can configure redelivery handling by using either of the following approaches:
You can use a wizard to create a concrete WSDL document that contains JMS binding and service information. The wizard is described in Creating JMS-Based Concrete WSDL Documents.
You can configure redelivery handling from the following wizard steps:
Request Consumer Configuration
Response Consumer Configuration
Click the Details button, which appears to the right of the Redelivery field. The Redelivery Information dialog box appears.
The Redelivery Information dialog box contains the following fields:
Delay. An entry consists of two numbers, separated by a colon (:). The first number is the number of times that the message has been delivered. The second number is how many milliseconds to wait before resending the message.
Assume that the entry is 5:1000. When a message is received for the fifth time, the message is delayed for one second. If you specify more than one entry, then you must separate the entries with a semicolon (;). For example:
5:1000; 10:5000 |
Termination. If you want to move the message to another destination, then select the Move option and set the remaining fields in the dialog box.
If you want to delete the message, then select the Delete option and set the Move/Delete After field.
Move/Delete After. The number of times after which the message is moved or deleted.
Move to Queue/Topic. Indicates whether the message should be moved to a queue or topic.
Move to Destination Name. Indicates the name of the destination where the message should be moved. The string can include the dollar sign ($) character, which is replaced with the original destination name.
You can configure redelivery handling by entering a specially formatted string in a WSDL document.
The string specifies what actions to take when the message is repeatedly redelivered. The string has the following format:
format := entry[; entry]* entry := index ":" action index := number (denotes the n-th time a message is seen) action := number (denotes delay in milliseconds) | "delete" | "move"(args) move := "queue"|"topic" | "same" ":" destname destname := any string, may include "$", which is replaced with the original destination name |
Redelivery Handling Example 1
Assume that the string is set as follows:
redeliveryHandling="5:1000; 10:5000" |
This example causes no delay up to the 5th delivery. When the message is seen for the 5th, 6th, 7th, 8th, and 9th time, a 1000–millisecond delay is invoked. For each time the message is seen thereafter, a 5000–millisecond delay is invoked.
Redelivery Handling Example 2
Assume that the string is set as follows:
redeliveryHandling="5:1000; 10:5000; 50:move(queue:mydlq)" |
This example causes no delay up to the 5th delivery. When the message is seen for the 5th, 6th, 7th, 8th, and 9th time, a 1000–millisecond delay is invoked. When the message is invoked for the 10th, 11th, ..., and 49th time, a 5000–millisecond delay is invoked. When the message is seen for the 50th time, the message is moved to a queue called mydlq.
Assume that the messages are received from Queue1 and the string is set as follows:
redeliveryHandling="5:1000; 10:5000; 50:move(queue:dlq$oops)" |
In thise case, the messages are moved to the destination dlqQueue1oops. The dollar sign ($) character denotes the original destination name. Instead of queue, you can specify topic or same. The value same denotes a queue if the message was received from a queue, or can denote a topic if the message was received from a topic.