Broker 10.5 | webMethods Broker Documentation | webMethods Broker Administration Java API Programmer’s Guide | Using Queue Browsers | Rearranging Queue Content | Inserting Documents
 
Inserting Documents
Use the BrokerLockedQueueBrowser. insertEventsAtHead method or insertEventsAtTail to insert one or more documents into the target queue.
The following example illustrates how to invoke the insertEvents method:
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
....
 
//Browse operation
try {
events = new BrokerEvent[2];
events[0] = new BrokerEvent(client, "API::Test")
events[1] = new BrokerEvent(client, "API::Test")
//Populate event fields
. . .
 
} catch(BrokerException ex) {
System.out.println("Failed to create new events.");
return;
}
 
//Insert at head operation
try {
browser.insertEventsAtHead(events);
} catch(BrokerException ex) {
System.out.println("Failed to complete insert at head operation.");
return;
}
//Insert at tail operation
try {
browser.insertEventsAtTail( events);
} catch(BrokerException ex) {
System.out.println("Failed to complete insert at tail operation.");
return;
}
. . .
//Various browse operations
. . .
 
//Close the queue browser
try {
browser.closeQueueBrowser();
} catch(BrokerException ex) {
System.out.println("Failed to close queue browser.");
return;
}