Ce contenu n'est pas disponible dans la langue sélectionnée.
2.11. Message Redelivery
Overview Copier lienLien copié sur presse-papiers!
- A transacted session is used and
rollback()is called. - A transacted session is closed before commit is called.
- A session is using
CLIENT_ACKNOWLEDGEandSession.recover()is called.
- On the broker, using the broker's redelivery plug-in,
- On the connection factory, using the connection URI,
- On the connection, using the
RedeliveryPolicy, - On destinations, using the connection's
RedeliveryPolicyMap.
Redelivery properties Copier lienLien copié sur presse-papiers!
| Option | Default | Description |
|---|---|---|
collisionAvoidanceFactor | 0.15 | Specifies the percentage of range of collision avoidance. |
maximumRedeliveries | 6 | Specifies the maximum number of times a message will be redelivered before it is considered a poisoned pill and returned to the broker so it can go to a dead letter queue. -1 specifies an infinite number of redeliveries. |
maximumRedeliveryDelay | -1 | Specifies the maximum delivery delay that will be applied if the useExponentialBackOff option is set. -1 specifies that no maximum be applied. |
initialRedeliveryDelay | 1000 | Specifies the initial redelivery delay in milliseconds. |
redeliveryDelay | 1000 | Specifies the delivery delay, in milliseconds. |
useCollisionAvoidance | false | Specifies if the redelivery policy uses collision avoidance. |
useExponentialBackOff | false | Specifies if the redelivery time out should be increased exponentially. |
backOffMultiplier | 5 | Specifies the back-off multiplier. |
Configuring the broker's redelivery plug-in Copier lienLien copié sur presse-papiers!
maximumRedeliveries to 0 on the destination).
redeliveryPlugin element. As shown in the following example this element is a child of the broker's plugins element and contains a policy map defining the desired behavior.
Example 2.17. Configuring the Redelivery Plug-In
- 1
- The
redeliveryPolicyEntrieselement contains a list ofredeliveryPolicyelements that configures redelivery policies on a per-destination basis. - 2
- The
defaultEntryelement contains a singleredeliveryPolicyelement that configures the redelivery policy used by all destinations that do not match the one with a specific policy.
Configuring the redelivery using the broker URI Copier lienLien copié sur presse-papiers!
Example 2.18. Setting the Redelivery Policy using a Connection URI
ActiveMQConnectionFactory connectionFactory =
new ActiveMQConnectionFactory("tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=4");
ActiveMQConnectionFactory connectionFactory =
new ActiveMQConnectionFactory("tcp://localhost:61616?jms.redeliveryPolicy.maximumRedeliveries=4");
Setting the redelivery policy on a connection Copier lienLien copié sur presse-papiers!
ActiveMQConnection class' getRedeliveryPolicy() method allows you to configure the redelivery policy for all consumer's using that connection.
getRedeliveryPolicy() returns a RedeliveryPolicy object that controls the redelivery policy for the connection. The RedeliveryPolicy object has setters for each of the properties listed in Table 2.3, “Redelivery Policy Options”.
Example 2.19. Setting the Redelivery Policy for a Connection
Setting the redelivery policy on a destination Copier lienLien copié sur presse-papiers!
ActiveMQConnection class' getRedeliveryPolicyMap() method returns a RedeliveryPolicyMap object that is a map of RedeliveryPolicy objects with destination names as the key.
RedeliveryPolicy object controls the redelivery policy for all destinations whose name match the destination name specified in the map's key.
FRED.JOE can only be redelivered 4 times.
Example 2.20. Setting the Redelivery Policy for a Destination