Message Push

H2O relies on user polling, but from time to time, we received suggestion in providing a push mechanism. Now, let me introduce briefly on what will be available in the next release - Message Push.


The idea is simple - invoke something after a message activity. But when you look closer, you will notice the possibility on what it can do is unlimited. One may want to push the message to a message queue, while one might simply want to dump it into their database. Thus, instead of confining which middleware will "Message Push" work with, we have designed a very flexible architecture which allow the developer to decide what they want to happen. We have introduced a new module called "EventModule" and a new interface "EventListener" into both ebMS and AS2. The "EventListener" defines 4 events that will be triggered by the message processor

User can define their action by creating their own EventListener by extending this base class. Then, they can package this, and register this class in the module.event.xml. Below is a diagram to illustrate the flow.


I am going to develop a simple listener to illustrate the work, to keep thing simple, the objective of the project is to pops up an alert, showing the message id of the received message. Since I am running on OS X, I will be using the Growl notification engine to do so. First, let's create the listener class and I am naming it as "". Instead of overriding all the four methods, I am only overriding the method "messageReceived".

Then, I need to register this listener to the event.module.xml

I packed the listener as "as2-sample-event-listener.jar" and put it into the AS2Plus plugin folder. Then, I need to update the plugin.xml to include this JAR file in the classpath. This step is important, since if you forget to do so, a ClassNotFound exception will be thrown.

All set, I simply need to restart H2O and all is well. Below is a video illustrating the behavior.

This ScreenFlow video requires a more recent version of the Adobe Flash Player to display. Please update your version of the Adobe Flash Player.

As a side note, do you notice the little twist near the end of the video? I am using a tool we built internally called MassSender to "fire" a lot of messages to H2O. This little tool is very efficient in determining the efficiency of H2O.

Moving On

My example is simply to illustrate the idea, you can extend the usage to integrate it with middle ware supporting JMS, IBM MQ or even AMQP. You can wait for our next release (we are now going through the testing phase) or you can get a beta version released on March 31, 2010 from this location. Send us your feedback and let us know what can be improved.

Discuss this in our forum

Posted by Ronnie Kwok on 03/31 at 05:50 PM