+

Search Tips   |   Advanced Search

Use the JMS asynchronous response message listener


JAX-WS includes a JMS asynchronous response message listener, which is used to receive responses to asynchronous JAX-WS requests that use the JMS transport. The JMS asynchronous response message listener is used in the appserver and application client environments.

JAX-WS provides support for invoking Web service operations asynchronously by using either a callback or a polling model. When the JAX-WS client uses the JMS transport to invoke asynchronous operations, the responses are received by the asynchronous response message listener. To learn how to use the JAX-WS asynchronous client invocation model, read about invoking JAX-WS Web services asynchronously.

The JMS asynchronous response message listener is used within the Web services client environment to receive incoming asynchronous responses when the client application is using the JMS Transport. The listener requires a connection factory and a queue to function correctly. Begin by configuring the connection factory and queue, and then specify the JNDI names of the connection factory and queue to the listener by setting Java system properties. The environment in which the client is running determines how the system properties are set.

The JMS asynchronous response message listener is started automatically by the Web services client runtime environment when the client invokes the first asynchronous JAX-WS operation using the JMS transport.

The connection factory and the queue configured with the asynchronous response message listener is used for all requests that are invoked within a particular Java process such as for the appserver or an application client container. We can share the connection factory among different Java processes. However, we cannot share a queue among Java processes.

 

  1. Determine if we want the JAX-WS client to use the JMS transport mechanism.

  2. For each Java process that will use JMS as a transport for asynchronous JAX-WS requests, configure the connection factory and queue that are used by the JMS asynchronous response listener for that process. You can share a connection factory among multiple Java processes, but we cannot share a queue among Java processes.

  3. For each Java process, set the com.ibm.websphere.webservices.jms.AsyncReplyQueueName and com.ibm.websphere.webservices.jms.AsyncReplyCFName Java system properties to specify the JNDI names of the queue and connection factory that are used by the JMS asynchronous response message listener for that process.

    If the JNDI name of the queue is the default value, jms/DefaultAsyncReplyQueue, then you do not need to set the AsyncReplyQueueName property. Likewise, if the JNDI name of the connection factory is the default value, jms/DefaultAsyncReplyCF, then you do not need to set the AsyncReplyCFName property as well.

    If wer client runs within the appserver environment, then set the properties as appserver system properties by using the admin console or the wsadmin command.

    If wer client runs within the application client container environment, then you should set the properties by using the –CCD option on the launchClient command line.

 

Results

Your JAX-WS Web services client is configured to use the JMS asynchronous response message listener to receive asynchronous response messages when using the JMS transport.

 

Example

Suppose that we have a JAX-WS Web services client that runs in the application client container environment and uses the JMS transport to communicate with the server. Suppose also that the client invokes asynchronous JAX-WS operations. We can create a connection factory with the JNDI name, jms/MyAppCF, and a queue with the JNDI name, jms/MyAppAsyncReplyQueue. When you invoke the client with the launchClient command, specify the JNDI names of the queue and connection factory as illustrated in the following command:

launchClient MyAppClient.ear \
   -CCDcom.ibm.websphere.webservices.jms.AsyncReplyQueueName=jms/MyAppReplyQueue \
   -CCDcom.ibm.websphere.webservices.jms.AsyncReplyCFName=jms/MyAppCF \
   <application arguments>

 

Related tasks


Implementing Web services applications with JAX-WS
Invoking JAX-WS Web services asynchronously
Wsadmin tool
Implementing JAX-WS Web services clients

 

Related


SOAP over JMS protocol
JMS endpoint URL syntax
Web services specifications and APIs