+

Search Tips   |   Advanced Search

Example: Code for creating a sequence


Your client application can use the WSRMSequenceManager, part of the WAS SPI for reliable messaging, to gain programmatic control over reliable messaging sequences. Use these code fragments as guidance for coding the reliable messaging client application to create a sequence.

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. The first of the following code examples includes code to create a WSRMSequenceManager object. If we need more information about working with this object, see Controlling WS-ReliableMessaging sequences programmatically.

 

Example

To create a new reliable messaging sequence, first create a WSRMSequenceProperties object:

import com.ibm.wsspi.wsrm.WSRMSequenceProperties 

.........

WSRMSequenceManager sequenceManager = WSRMSequenceManagerFactory .getInstance().createWSRMSequenceManager();

WSRMSequenceProperties sequenceProperties = sequenceManager .createNewWSRMSequenceProperties();

To set the available properties use the following methods:

  /**
   * Sets the target provider endpoint.
   * A null value will cause a NullPointerException when the WSRMSequenceProperties object is used.
   * 
   * @param providerEndPoint The target service endpoint URI
   */
  public void setTargetEndpointUri(String providerEndPoint);
  
  /**
   * This is used to indicate that a response flow is required between the provider and requester and the response
   * flow will be established at create sequence time   
   * 
   * By calling this method it will indicate that a response flow is required.
   */
  public void setUseOfferedSequenceId();
  
  /**
   * Set the Soap version for RM protocol messages.
   * The default value for this property is WSRMSequenceProperties.SOAP_11
   * 
   * @param soapVersion
   */
  public void setSoapVersion(int soapVersion);
  
  /**
   * If the Sequence Acknowledgement messages are to be sent back asynchronously call this method.
   *
   */
  public void useAsyncTransport();


To create the reliable messaging sequence use the createNewWSRMSequence method on the WSRMSequenceManager:

  /**
   * Initiates a new sequence handshake between this client and the target EPR specified in the    
   * WSRMSequenceProperties instance.
   * 
   * This sequence will only be valid for the client issuing the createNewWSRMSequence call.
   * 
   * When returning from this call, there is no guarantee that the sequence has been established.
   * 
   * @throws NullPointerException if the sequenceProperties object is null, or the target EPR is null
   * 
   * @param clientObject The JAX-WS Dispatch instance, or the Dynamic Proxy client instance. 
   * @param sequencePropeties The properties for creating the reliable messaging sequence
   * @throws WSRMNotEnabledException 
   * @throws WSRMSequenceAlreadyExistsException 
   */
  public void createNewWSRMSequence(Object clientObject, QName portQName, WSRMSequenceProperties sequencePropeties) 
  
  throws WSRMNotEnabledException, 
         WSRMSequenceAlreadyExistsException;





 

Related tasks

Learn about WS-ReliableMessaging
Controlling WS-ReliableMessaging sequences programmatically

 

Related

Example: Code for sending an acknowledgement request
Example: Code for closing a sequence
Example: Code for terminating a sequence
Example: Code for waiting for a sequence to complete