How should I end/exit from my Sandesha2 client code?
Submitted on August 15, 2006 - 22:50. Story : Project :
Apache Sandesha2 or rather any other WSRM implementation has to exchange several protocol specific messages with an endpoint with which you are trying to communicate reliably. Because of this, even though you may be doing only a single invocation from your client code Sandesha2 would most probably be exchanging several other messages as well. The amount of time that is taken for this depends on your system performance and on the quality of the network between you and the other endpoint. Because of this, even after your invocation you must give Sandesha2 some time to finish its work properly. Exiting the client program immediately, without some time for Sandesha to finish processing, will not guarantee a reliable delivery of the message. Sandesha2 client API provide several mechanism which could be used to detect when the work of the Sandesha2 system is over and when you could safely exit the program. The first mechanism we are going to talk about asks Sandesha2 to simply block the program till its work is over. This can be done using following functions of the Sandesha2 API:
void waitUntilSequenceCompleted(ServiceClient serviceClient);
void waitUntilSequenceCompleted(ServiceClient serviceClient, String sequenceKey);
void waitUntilSequenceCompleted(ServiceClient serviceClient, long maxWaitingTime);
void waitUntilSequenceCompleted(ServiceClient serviceClient, long maxWaitingTime,
String sequenceKey);
The first two functions asks Sandesha2 to simply block forever and only break if the sequence is finished properly. Out of these two, the second function gets a sequence key value as an argument which can be used when you have initiated several sequences using the same ServiceClient object. The last two functions asks Sandesha2 to block only until a given time expires. The waiting time is given as a millisecond value to the maxwaitingTime parameter. Note that the the fourth function takes a sequence key as a parameter as well. Another method to correctly detect whether Sanesha2 has finished its work is to use SandeshaReports in a polling fashion. For example, assume you are invoking a Web service with WSRM supports using Sandesha2. Now you can always ask for a SequenceReport describing that sequence. What you have to do is keep checking the status of that sequence. When the status is changed to TERMINATED, you can safely assume that Sandesha2 has finished its work and you can exit your program.
Applies To:
Apache Sandesha2/Java post 1.0 versions
- Login or register to post comments
- Printer friendly version
- 1169 reads










