General J2EE: J2EE and raw TCP traffic
I am figuring out the best way to communicate with propietary software through J2EE software, in the past, we went the complicated route and created an mbean to forward traffic to different clients, but between upgrading application servers the mbean was difficult to port and stuff. I recently went with a simple SESSION bean and opened a raw socket connection to the external tcp server, and this method worked fine, but I was wondering how others did it.
The software is GIS/ArcIMS, I may want to communicate with different webservers in the future.
I have used the same solution. Note that the stateless session bean has instance pooling, and the EJB spedification guarantees that only one thread/client uses one instance at the same time. This means you can open the socket in ejbCreate and close it in ejbRemove [section 7.8.1 in the EJB 2.1 specification].
With this design, the instance pool for statless session beans on the application server will also serve as a connection pool for your TCP/IP sockets.
Note that your bean will be non-transactional, and should be declared as "NotSupported" in the deployment descriptor.