Messaging is used for two things
The messaging system offers plugin capability, for example the WS-BaseNotification support is realised as a plugged-in messaging provider.
To send a message asynchronously to a service instance, you can use the following code.
Message m= new Message(...); //send message to instance with id "instanceid" Kernel.getMessaging().getQueue(instanceid).publish(m);
The publish() method returns immediately. Messages are stored in a persistent queue.
The target WS-Resource can pick up its message at any time as follows:
//get messages
PullPoint p=Kernel.getMessaging().getPullPoint(getUniqueId());
while(p.hasNext()){
Message m = p.next();
//process message...
}
There is a hook method postActivate() that is called immediately after the WS-Resource is activated, that is immediately before the actual web method is invoked. This can be overwritten in your service class.
If you want to plug in your own communication scheme (such as sending messages out using web services), you can write a class implementing IMessagingProvider, and return your own Publisher implementation. Check the WS-BaseNotification code for an example.