Design Question - Is Servlet the right solution or should be EJB

Discussions

Web tier: servlets, JSP, Web frameworks: Design Question - Is Servlet the right solution or should be EJB

  1. We had a systems architect design our system and after he left, we found numerous design flaws and are now re-visting the design. First let me describe a little about our application. We are using or planning to use Apache, JRun, Oracle, and SonicMQ.

    Our client application is a Java app. We receive orders from the client, do some business processing/write to db and need to send the order message to an external client to get filled and receive the report back. We need to open a persistent TCP/IP socket connection to the external client. They only allocate 1 IP and 1 port for us to connect with. I beleive we can't use connection pooling because they only allocate 1 port for us to use.

    We need to establish the socket connection to the external Server at startup and have the same connection available to us when sending any and all orders. We don't want to shutdown and startup the connection everytime we have to send a message. Any moment of time we can have up to 1000 messages/orders generated per second.

    This whole system was designed using Servlets and Servlets chaining. Now we are finding that was the wrong approach and the architect might not have understood our business requirements.

    Am I understanding this correctly and going in the right direction when I think that we should be using an EJB instead of a Servlet. Is the only way to have a persistent TCP/IP socket connection is through an EJB and not Servlets ?

    I just wanted to get some opinions from people because I don't want to make another mistake and choose the wrong technology. Any input in the design would be greatly appreciated.

    Thanks in advance for your help.
  2. First, TCP manages multiple connections to the same "listening" address (ip+port) so having a single IP and a single port allocated to you does not mean you can make just a single connection. You can have multiple connections and pool them.

    Second, EJBs are no better fit for keeping TCP connections than Servlets. Maybe you should look into the RMI concept.