I have a situation where when the customer logs in, I need to get some data(coupons) from a legacy server using socket(TCP/IP) connection. What is the best way to implement this? Can I use a session bean to connect directly to the server using sockets?
Thnaks in advance,
Session beans (and EJBs in general) may act as socket clients, so you can simply connect to the legacy system directly. If this legacy system is complex and you expect many requests, it might be preferrable to implement a resource connector for the legacy system. This gives you some advantages regarding thread management, pooling, security, etc. But it may take some time to implement such a solution, especially if you're not familiar with the JCA.
I cannot speculate what approach would be better for you without knowing your application. I suggest you read up about the JCA (some good resources on java.sun.com) and decide for yourself.
Thanks for the reply. I will go through JCA.
If I use a session bean, what would happen if the socket response time is really long? Will that affect any other components of the system?
Also, I might need to keep the socket connection once it is connected( until one of the systems die).I doubt if I will be able to use a session bean in this situation.
If you are working within a transaction you will have issues if the socket blocks for longer than the transaction timeout.
In BEA/Weblogic the timeout is checked when you enroll a resource in the transaction or you attempt to commit the transaction.