Broker 10.5 | webMethods Broker Documentation | webMethods Broker Administration Java API Programmer’s Guide | Using Queue Browsers | Rearranging Queue Content | Deleting Documents
 
Deleting Documents
Use the BrokerLockedQueueBrowser. deleteEvents method to remove one or more documents from the queue. In order to use this method, you must know the receipt sequence numbers of the documents that you are trying to delete. The receipt sequence number of a document is unique and is assigned when the document is placed in the queue.
You can use the BrokerEvent.getReceiptSequenceNumber method to access the receipt sequence number of a document. Documents with an "unacked" status can also be deleted using this API. For more information, see Identifying "Unacknowledged" Documents.
The following example illustrates how to delete client queue documents:
BrokerAdminClient admin = null;
BrokerLockedQueueBrowser = null;
BrokerEvent[] events = null;
 
//Create a Broker admin client
try {
admin = new BrokerAdminClient(broker_host,
broker_name,
null,
"admin",
"QueueBrowser-LOCKED",
null);
} catch(BrokerException ex) {
System.out.println("Failed to create admin client.");
return;
}
. . .
//Create a locked queue browser
...
 
//Browse operation
try {
events = browser.browseEvents(max_events, msecs);
} catch(BrokerException ex) {
System.out.println("Failed to complete browse operation.");
return;
}
//Delete operation
try {
long seqn[] = new long[events.length];
 
for (int i = 0; i < events.length; ++i) {
seqn[i] = events[i].getReceiptSequenceNumber();
}
browser.deleteEvents( seqn);
} catch(BrokerException ex) {
System.out.println("Failed to complete delete operation.");
return;
}
. . .
//Various browse operations
. . .
 
//Close the queue browser
try {
browser.closeQueueBrowser();
} catch(BrokerException ex) {
System.out.println("Failed to close client queue browser.");
return;
}