Broker 10.15 | webMethods Broker Documentation | webMethods Broker Messaging Programmer's Guide | Coding Messaging Client Applications | C# Messaging Clients | Application Code | Using a Message Selector
 
Using a Message Selector
The server application implements a message selector that filters messages based on a customer's geographical region.
You enter the message selector value (currentRegion) as a command line argument at server startup. If you enter a value of "All," the server receives a message regardless of region (that is, message selection is disabled). If you enter the value of a valid region ("East" or "West"), the server enables message selection, allowing the listener to receive only messages from the specified region.
if (currentRegion.Equals(ApplicationConstants.ALL_REGIONS,
StringComparison.InvariantCultureIgnoreCase)) {
receiver = session.CreateConsumer(destination);
} else {
receiver = session.CreateConsumer(destination, "location = " +
currentRegion, false);
}
You specify the valid regions in determineRegion() in the server application.
private static String DetermineRegion(String regionName)
{
String region;
if (regionName.Equals("East",
StringComparison.InvariantCultureIgnoreCase)) {
region = ApplicationConstants.EAST_REGION; }
else if (regionName.Equals("West",
StringComparison.InvariantCultureIgnoreCase)) {
region = ApplicationConstants.WEST_REGION; }
else if (regionName.Equals("All",
StringComparison.InvariantCultureIgnoreCase)) {
region = ApplicationConstants.ALL_REGIONS;
...
return region;
}