I have successfully implemented both polling and callback client side asynchronous examples, but now I am interested in implementing a web service with server side asynchrony. The infrastructure is Java EE using JBoss AS 6.x.
The pattern (as I understand it) that I am trying to implement would involve two web service operations, one to initiate a request and a second to check to see if a request is done and retrieve the results.
I am guessing that, since picking up the results doesn't involve a long query, I don't need JMS, I can simply query the database to see if results are ready. So, the second operation would be:
So, I have many questions. I have seen some references to server side support for asynchrony, but they all seem to be server specific in some way. For example, I have seen a diagram describing this first operation exactly, but it seems to be OC4J specific. If anyone can direct me to an generic example or tutorial implementing something like this, please do. Other subleties might be, should I use the JMS message ID as the correlator to return to the client? I am assuming I should use CLIENT-ACKNOWLEDGE as the JMS session mode so that the MDB can send a reply to the web service and then remove the message from the queue. Or, should I even bother? Should the web service endpoint just generate a JMS message, pop it in the queue and return the message ID directly to the service client without going through all the rigamarole of having the MDB send back a correlator via JMS queue 2? [edit: Actually, the more I consider it, it seems wrong that the web service would send a message and then, what, block on waiting for a reply on queue 2? ]
Correlation id can be generated at step 2 and immediately returned to the client. That reduces additional hops before responding to the client. Generating a persistent message into the queue should suffice. I also dont see the need for two queues. I prefer an application generated correlation id.