Broker 10.15 | webMethods Broker Documentation | webMethods Broker Client C API Programmer's Guide | Using Event Filters | Using BrokerFilters
 
Using BrokerFilters
 
Destroying Broker Filters
Obtaining Filter Strings
Obtaining Event Type Names
Converting Broker Filters to Strings
You client application may create a BrokerFilter using the awNewBrokerFilter function. A BrokerFilter may be used locally by the client application, in conjunction with the awMatchFilter function, to determine if a particular event type matches the filter.
When creating a BrokerFilter, you must specify an event type name and a filter string. You may then use the awMatchFilter function to check any events that your client application might receive.
The following example shows a code excerpt that creates three filters for use by a client application. The awMatchFilter function is then used to determine if the event matches each filter's criteria.
. . .
awNewBrokerFilter(my_client,"Type1",
"(A<B) && ((C+12) >(D*3))",&f1);
awNewBrokerFilter(my_client, "Type1",
NULL,&f2);
awNewBrokerFilter(my_client,"Type2",NULL,&f3);

awGetEvent(my_client,&my event);
awMatchFilter(f1,my_event,&is_special);
awMatchFilter(f2,my_event,&is_of_type1);
awMatchFilter(f3,my_event,&is_of_type2);
if (is_special) {
/* A special case of Type1 events that requires special processing */
. . .
} else if (is_of_type1) {
/* A Type1 event */
...
} else if (is_of_type2) {
/* A Type2 event */
. . .
}
To do this same processing without BrokerFilters, your code would look like that shown in the following example:
. . .
awGetEvent(my_client,&my_event);
awGetEventTypeName(my_event,&name);
awGetIntegerField(my_event,"A",&a);
awGetIntegerField(my_event,"B",&b);
awGetIntegerField(my_event,"C",&b);
awGetIntegerField(my_event,"D",&d);
is_special = (strcmp(name,"Type1")==0) && (a<b) && ((c+12) >(d*3));
is_of_type1 = (strcmp(name,"Type1")==0);
is_of_type2 = (strcmp(name,"Type2")==0);
free(name);
. . .