|
You can use Sandesha2 listeners to get notified when specific events happen in the Apache Sandesha2 system. You will most probably be registering your listener in the client code. Calling back could happen within any time of the execution of Sandesha2.
|
Date: Tue, 15th Aug, 2006
Level:
Reads: 3148
Discuss this article on Stack Overflow
|
|
|
|
Chamikara Jayalath Software Engineer WSO2 Inc. |
| |
|
The method signature of the current Sandesha2 Listener interface is given below.
public interface SandeshaListener {
public void onError(AxisFault fault);
public void onTimeOut(SequenceReport report);
}
To add a Sandesha2 listener first you have to implement this with your callback handling logic. Then you have to set an object of that as a property to the Options object. An example code is given below:
clientOptions.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, new SandeshaListenerImpl ());
After registering the object you will be notified in following events.
1. When a RM control message gets returned with a SOAP Fault.
As you know the fault that gets thrown in response to application messages will be handled at by your application level code. But who will handle the fault that is returned in response to RM control messages. For example, if your RM Create Sequence gets rejected due to a security violation, how will you know that and how can you handle that? This is an ideal use case for the Sandesha2Listener. In such a situation the onError method of that would be called with the Fault as a parameter.
2. When a sequence times out.
When you give your application messages to Sandesha2 and if it is not possible to transmit it to the other side in its first try, Sandesha2 layer will retry several times to send it. But if it cannot send the messages even after a number of retries it will give up and declare the sequence as timed out. If you want to handle this timing out programatically again you have to use a SandeshaListner. Here you have to use the onTimeOut method, which will be called passing a SequenceReport describing the current status of the sequence.
Applies To:
Apache Sandesha2/Java post 1.0 versions