+

Search Tips   |   Advanced Search

Use the JAX-WS JMS asynchronous response message listener

JAX-WS includes a Java Message Service (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 application server 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 application server 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 used by the JMS asynchronous response listener for that process. We 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 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 we do not need to set the AsyncReplyQueueName property. Likewise, if the JNDI name of the connection factory is the default value, jms/DefaultAsyncReplyCF, then we do not need to set the AsyncReplyCFName property as well.

    If wer client runs within the application server environment, then set the properties as application server system properties using the console or wsadmin.

    If wer client runs within the application client container environment, then you should set the properties 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

  • Implement web services applications with JAX-WS
  • Invoking JAX-WS web services asynchronously
  • wsadmin scripting tool
  • Implement static JAX-WS web services clients

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