Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Subscribing to and Receiving Events | Receiving Events in the Get-Events Model | Detecting Redelivered Events | Manual Redelivery Counting
 
Manual Redelivery Counting
When you enable manual counting mode, your client must explicitly update the counter by calling BrokerClient.incrementRedeliveryCount after it successfully receives an event from the Broker. (Only the client session that receives an event can update the redelivery count for that event.)
After incrementing the counter, your client must immediately dispatch the event and the counter value its user code. The user code must accept the redelivery count (an integer) and take appropriate steps to process the event if the value of the counter is greater than zero.
The following snippet illustrates how you would count redeliveries in manual mode.
static String broker_host = "localhost";
static String broker_name = null;
static String client_group = "sample";
 
BrokerConnectionDescriptor d;
BrokerClient c;
BrokerEvent e;
long rsn;
boolean rd_mode = true;
int rd_count;
. . .
/* -----------------------------------------------*/
/* Create descriptor and enable Manual Redelivery */
 
try {
d = new BrokerConnectionDescriptor;
d.setRedeliveryCountEnabled(rd_mode);
} catch (BrokerException ex) {
System.out.println("Error on create descriptor\n"+ex);
return;
}
/* ----------------------------------------------- */
/* Create client using connection descriptor */
 
try {
c = new BrokerClient(broker_host, broker_name,
null, client_group,
"Subscriber Sample #1",d);
} catch (BrokerException ex) {
System.out.println("Error on create client\n"+ex);
return;
}
. . .
/* -------------------------------------------------*/
/* Get event, update count, pass event to user code */
 
while (dispatchingDocuments() == true) {
e = BrokerClient.getEvent();
rsn = e.getReceiptSequenceNumber();
rd_count = e.getRedeliveredCount();
if (c.incrementRedeliveryCount (rsn) != OK)
break;
if (dispatchToUserCode(e, rd_count) == OK) {
c.acknowledge(rsn);
}
}
. . .