Your webservice interface needs to offer two functions: submit
and poll
.
- The client calls
submit
which in turn sends the request as a JMS message on the incoming queue, and returns the message ID.submit
returns after that. - The request processing runs asynchronously. For example a message driven bean (MDB) listens on the incoming queue, processes the message, and puts the result on an outgoing queue. It sets the correlation ID of the result message to the message ID of the incoming request. The correlation ID is required to connect the request and its result.
- The client calls the
poll
function with the message ID (as returned bysubmit
) as an argument:poll
checks the result queue using a JMS message selector on the correlation ID. It returns "not yet completed" or the result. The client possibly needs to callpoll
multiple times to get the result.
Notes:
- A JMS message selector is a filter (like a where clause in a database): It is required in this scenario to identify the result for a given request.
- Javadoc of setJMSCorrelationID