Broker 10.5 | webMethods Broker Documentation | webMethods Broker Administration Java API Programmer’s Guide | Using Queue Browsers | Filters on a Queue Browser | Setting Multiple Filters on Queue Browser
 
Setting Multiple Filters on Queue Browser
Use the setFilters method to set up multiple filters for queue browse operations. Note that queue browser filters are applicable only to the browse operation and not other queue browser operations, such as insert or delete operations.
If the queue browser already has one or more filters, the new filters are added to the list. If a filter is already present for a document type, the existing filter will be overwritten with the new filter. When filters are set for the queue browse operations, only documents matching those filters are processed.
The following example illustrates how to set multiple filters:
BrokerAdminClient admin = null;
BrokerQueueBrowser browser = null;
BrokerFilterDescriptor[] filters = new BrokerFilterDescriptor[3];
 
filters[0] = new BrokerFilterDescriptor(""API::Test", "test_int < 10");
filters[1] = new BrokerFilterDescriptor(""API::Test1",
"my_string.contains("Hello"));
filters[2] = new BrokerFilterDescriptor(""API::Test2", "test_byte%2 == 0"));

//Create a Broker admin client
try {
admin = new BrokerAdminClient(broker_host,
broker_name,
null,
"admin",
"QueueBrowser-UNLOCKED",
null);
} catch(BrokerException ex) {
System.out.println("Failed to create admin client.");
return;
}
. . .
//Create a queue browser
. . .
//Set multiple filters
try {
browser.setFilters(filters);
} catch(BrokerException ex) {
System.out.println("Failed to set multiple filters.");
}
. . .
//Various browse operations
. . .
//Close the queue browser
try {
browser.closeQueueBrowser();
} catch(BrokerException ex) {
System.out.println("Failed to close queue browser.");
return;
}