Connecting to 3rd party through servlet.

Discussions

Web tier: servlets, JSP, Web frameworks: Connecting to 3rd party through servlet.

  1. Connecting to 3rd party through servlet. (2 messages)

    I need to write a servlet that will receive a request from a "client" and forward that request to 3rd party. The 3rd party will process the request return a response to the servlet and the servlet will return a formated response back to the "client". It is important that all this happen in one request. The client must not be able to request at a later time the response by the 3rd party. Also the servlet will read the request from the client and forward the message to the appropriate 3rd party. So there can be multiple 3rd parties, using different network proctocols, message protocols etc...

    The question is should it be done straight through the servlet, where the servlet will determine what party the message should go to and call a class that will connect to the appropraite 3rd party? Or should the servlet add a message to the queue and have the appropriate message driven bean do the work. The problem I see with message driven bean is how is the response from the 3rd party sent back to servlet so it can respond back to the "client"
  2. If you are required to process all these requests/responses as a single operation, I don't see the need to use MDB, since your servlet would need to wait for the response before it gets back to the client anyway (BTW, it is possible to get the response from MDB by setting up a "return" queue, but since this is out of the question so I don't goto detail here).

    It is ok to trigger 3rd party method call within the servlet, but you have to be careful about the response time from each 3rd party, especially when there is a loaded condition. Also, for programming clarity, you may want to abstract the code of choosing which 3rd party in a "broker" class.
  3. Why would MDB be out of the question? I guess cause your saying is the client would have to connect a second time to get back the response right? Or a servlet is capable of waiting for a "return" queue?

    As for the second method, each 3rd party has it's own time out values, network protocols, message protocols etc... It doesnt matter we usualy would tell the "client" to wait a few extra seconds more then the 3rd parties time out value, so that there client has a chance to get back a response or finally just disconect. What do you mean by loaded condition?

    I also like the "broker" class idea where it can call the appropriate session beans that can forward the requests to the proper 3rd parties...

    The other small issue is... Some of the 3rd parties require that a connection to them be always opened. I guess it would be possible to set up the connection on the session beans create methods and disconnect on the destroy methods. The connection must be kept on the application session and not per user session. It is possible to load a session bean at application start up?