EJB programming & troubleshooting: How To: get an MDB to respond back to servlet
- Posted by: Carl Daver
- Posted on: July 28 2004 19:20 EDT
I am in a situation where i need to write a servlet that will receive a request from a "client" create an XML doc from the req and push it to a message queue.
Then i need to somehow consume the response message, convert it into XML and pass the XML to the servlet.
My question is how do i achieve this, asynchronously, ie i do not want the servlet to wait till msg is returned.
Cant do threads wih MDB - WSAD screams.
Is there any way of having an MDB call a servlet after finishing???
Or writing a session bean to do the consuming and saying Parent is servlet. Does the servlet need to be serialized?
cause i am using logger and stuff.
How do i do this????? Please Help, been at it whole day
What do you have to do with the message in the MDB/Session bean.......
You should be able to just get the request from the Client, process the message in a class (POJO - Plain Old Java Object) and send the response back to the client.
Marshalling and unmarshalling of the XML can be done in the servlet itself. You must also understand that MDBs are not meant to be called from any client (say servlet etc)
Refer to http://www.theserverside.com/discussions/thread.tss?thread_id=19628
The basic property of Asynchronous is do decouple the client and business object, so that the request will be processed even if the server is down at the time of requesting.
So I don't think you can do that. Even if you do that in an indirect way, you will not use the advantage of having Asynchronous system in your application. That is equivalant to servlet --> Session Bean.