Administratively Viewing Contents of a Locked Client Queue
For an administrative client to create a queue browser and examine client queue content in a locked mode, follow these steps.
1. Create a queue browser in locked mode using the
BrokerAdminClient.createLockedClientQueueBrowser(String client_id) method. This will acquire a client queue lock to prevent further changes to the client queue. Note that even though the target client queue is locked, the
Broker will continue to queue incoming documents according to the client's subscription.
Acquiring a Queue Lock for instructions.
2. Set a filter or filters, if needed. It is important to note that once a filter is set for the queue browser, all browse operations will consider only documents that pass the filters. See
Filters on a Queue Browser for instructions.
The following example illustrates how to examine a client queue in LOCKED mode:
BrokerClient client = null;
BrokerAdminClient admin = null;
BrokerLockedQueueBrowser browser = null;
BrokerEvent[] events = null;
int max_events = 100; //Maximum number of documents to be browsed
int msecs = 30000; //Timeout for the browse operation
//Create a Broker client
try {
client = new BrokerClient(broker_host,
broker_name,
client_id,
client_group,
"QueueBrowser",
null);
} catch(BrokerException ex) {
System.out.println("Failed to create client.");
return;
}
//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
try {
browser = admin.createLockedClientQueueBrowser(client.getId());
} catch(BrokerException ex) {
System.out.println("Failed to create locked client queue browser.");
return;
}
. . .
//Browse operation
try {
events = browser.browseEvents(max_events, msecs);
} catch(BrokerException ex) {
System.out.println("Failed to complete browse operation.");
return;
}
. . .
//Various browse operations
. . .
//Close the queue browser
try {
browser.closeQueueBrowser();
} catch(BrokerException ex) {
System.out.println("Failed to close queue browser.");
return;
}