Detecting Redelivered Events
When you enable the Broker's redelivery counting feature in the connection descriptor, your client can detect whether it has received an instance of a particular event more than once. A redelivery is indicated if an event's redelivery count is greater than zero.
In the BrokerConnectionDescriptor, you enable the redelivery counter, and use it in one of two modes, manual or automatic. To able the redelivery counter, you use the setRedeliveryCountEnabled method. The default mode is manual. In this mode your client must explicitly increment the redelivery counter.
To enable automatic mode, call setAutomaticRedeliveryCount after you call setRedeliveryCountEnabled. In automatic mode, the Broker automatically increments the redelivery counter when it re-sends an event to a client.
In either mode, the Broker sets the counter to zero the first time it sends an instance of an event to the client.
The following table summarizes the methods associated with the redelivery feature:
Method | Description |
BrokerConnectionDescriptor. setRedeliveryCountEnabled | Enables the redelivery counter in the connection descriptor. |
BrokerConnectionDescriptor. getRedeliveryCountEnabled | Returns the current value of the redelivery counting option from the connection descriptor. |
BrokerConnectionDescriptor. setAutomaticRedeliveryCount | Sets the redelivery counting option to automatic mode. The default value is manual mode. |
BrokerConnectionDescriptor. getAutomaticRedeliveryCount | Returns the current value of the automatic redelivery option from the connection descriptor. You use this method to determine whether the redelivery counter is configured for automatic or manual mode. |
BrokerEvent.getRedeliveryCount | Returns the current value of the redelivery counter. |
BrokerClient.incrementRedeliveryCount | Increments the redelivery counter by one. |
Note:
The redelivery counter applies only to guaranteed events. Volatile events always have a redelivery count of -1. Additionally, if a client does not enable redelivery counting, all events that it receives will have a redelivery count of -1.