Broker 10.15 | webMethods Broker Documentation | webMethods Broker Administration Java API Programmer’s Guide | Using Queue Browsers | Rearranging Queue Content | Modifying Documents
 
Modifying Documents
Use the modifyEvents method to modify one or more documents on the target queue. A modify operation is equivalent to an "in-place replacement" of documents. You can only perform a modify operation from a BrokerLockedQueueBrowser object. Documents with "unack" status cannot be modified. The replacement document should match the storage type of the document that is being replaced.
The following example illustrates how to modify queue documents:
BrokerAdminClient admin = null;
BrokerLockedQueueBrowser browser = 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 on Broker client queue or forwarding queue
for a remote Broker
...
...
 
//Set cursor position to head
try {
browser.setPosition(0);
} catch(BrokerException ex) {
System.out.println("Failed to complete setPosition operation.");
return;
}
. . .
//Browse operation
try {
events = browser.browseEvents(2, 10000);
} catch(BrokerException ex) {
System.out.println("Failed to complete browse operation.");
return;
}
//Swap events in position 0 and 1
try {
long seqn[] = new long[2];
BrokerEvent[] new_events = new BrokerEvent[2];
 
seqn[0] = events[0].getReceiptSequenceNumber();
seqn[1] = events[1].getReceiptSequenceNumber();
new_events[0] = events[1];
new_events[1] = events[0];
 
browser.modifyEvents(seqn, new_events);
} catch(BrokerException ex) {
System.out.println("Failed to complete modify operation.");
return;
}
. . .
//Various browse operations
. . .
//Close the queue browser
try {
browser.closeQueueBrowser();
} catch(BrokerException ex) {
System.out.println("Failed to close queue browser.");
return;
}