Back to Notification Service Examples Page
The Filter example uses the Custom Filter code from the Notification Service User Guide. The example illustrates how to use a simple custom filter to make sure only the events the consumer is interested in reach the consumer. The supplier sends events that have a height property and a length property. The height and length property can be between 0 and 60. The filter checks the height property of the structured event is between 10 and 20 and that the length property is between 20 and 40. If the event meets these criteria the consumer will receive it.
This example consists of two components:
PushSupplier.java: The PushSupplier uses the simple push model to send events to the event channel. The PushSupplier will perform the following tasks:
PushConsumer.java: The PushConsumer uses the simple push model to receive messages from the Notification Service. The MyPushConsumer will perform the following tasks:
MyFilter.java: MyFilter is a simple custom filter that uses a filter constraint to check that the height property of a structured event is in an interval between 10 and 20 and the length property of a structured event is in an interval between 20 and 40. The filter is added to the push supplier proxy by the PushConsumer.
bin
directory of the JDK and the
bin
directory of the OpenFusion distribution.
From the command line:
server -start NotificationService
From the Administration Manager:
Start the Admin Manager, right click on the NotificationService node and select Start from the pop-up menu.
run com.prismt.cos.CosNotification.examples.Filter.PushConsumer
run com.prismt.cos.CosNotification.examples.Filter.PushSupplier
To stop the above processes press Ctrl-C in each window.