All the following command runs at WSNT home directory.
1. Compile WS-Notification package:
Type "ant"
2, run TestController:
source setenv.sh
java wsnt.demo.leadCallBack.TestController
You can see that the notification consumer is start, subscription is created, and "Doing other stuff" is displayed.
3, run testpublisher: (in a new window.)
source setenv.sh
java wsnt.demo.TestPublisher -consumer rainier.extreme.indiana.edu:12345 -topic AAA -message "Thredd done."
then run:
java wsnt.demo.TestPublisher -consumer rainier.extreme.indiana.edu:12345 -topic AAA -message "Decode done."
After running the two commands, you can see that the notification consumer receives the two messages and shuts down the service and deletes the subscription. Then exit the program.
See LeadEventCallBack.java for a sample implemetation of the interface EventCallBack.java. It has only one method needs to be implemented:
public boolean deliverEvent(String eventString);
Parameter: The eventString is the message string extracted from the WS-Notification SOAP message.
Return value: If you want the NotificationConsumer to shut down after your return, return TRUE. Otherwise, return false.
See comments below in the code:
public static void main(String[] args) {
StopableNotificationConsumer nc = new StopableNotificationConsumer();
LeadEventCallBack myEventCallback=new LeadEventCallBack();
//set EventCallBack
nc.setEventCallback(myEventCallback);
//Set brokerURL=localhost:12345
//Set Topic=AAA
//listening to port 19999, non-blocking
nc.startNotificationConsumer("rainier.extreme.indiana.edu:12345","AAA",19999);
//method in myEventCallback Implementation, not required in Callback Interface.
//Add expected messages
myEventCallback.addExpectedMessage("Decode done.");
myEventCallback.addExpectedMessage("Thredd done.");
//launch other components
System.out.println("Doing other stuff");
//Wait for all messages after launching all the components, blocks here. After all messages arrives, it will shut down notification
//consumer and delete subscription.
nc.waitAllMessages();
//shut down other components after all "Done" messages arrive
}
Contact: yihuan@cs.indiana.edu