Example: Code for waiting for a sequence to complete
Your client application can use the WSRMSequenceManager, part of the WAS SPI for reliable messaging, to gain programmatic control over reliable messaging sequences. Use the waitUntilSequenceCompleted method on the sequenceManager to ensure that reliable messaging state is released after the client finishes messaging.
The WAS SPI for reliable messaging always uses the static policy set configuration that is applied to the client from which the SPI is called. It does not use any alternative policy set that is subsequently configured by WS-Policy to meet the requirements of a WS-Policy intersection.
For the client application to gain programmatic control over reliable messaging sequences, it needs access to a WSRMSequenceManager instance. For information and example code explaining how to achieve this, see Controlling WS-ReliableMessaging sequences programmatically.
Example
To wait for a reliable messaging sequence to complete, you use a method call that ensures that all messages have been sent and acknowledged by the target service. After the sequence is completed, it is terminated and cleaned up. By closing sequences programmatically, you limit the number of open sequences a single client has to support in a single JVM at one time.
There are two ways of using the waitUntilSequenceCompleted method:
public boolean waitUntilSequenceCompleted(Object clientObject, QName portQName, String endPointUri, long waitTime)This method call waits for the specified waitTime for the reliable messaging sequence to complete. If the sequence does not complete in the specified time, the method returns false. If the sequence does complete in time, the method returns true.
public boolean waitUntilSequenceCompleted(Object clientObject, QName portQName, String endPointUri)This method call does not return until the reliable messaging sequence is completed.
Related tasks
Learn about WS-ReliableMessaging
Controlling WS-ReliableMessaging sequences programmatically
Related
Example: Code for creating a sequence
Example: Code for sending an acknowledgement request
Example: Code for closing a sequence
Example: Code for terminating a sequence