We would like to serve some client requests within our Java EE application server (JBoss 4.2.3). I read that the Java EE spec doesn't allow opening a socket from an enterprise bean. But the spec suggests no alternatives.
Specifically, enterprise beans should not:
- listen on, accept connections on, or multicast from a network socket
So the question is: What can I do to serve some binary tcp based protocols (not http) from within an application server?
Here someone suggests to implement a resource adapter. Is this the way you have to go or are there other (easier) solutions?
ServerSocket is a java.net class that provides a system-independent implementation of the server side of a client/server socket connection. The constructor for ServerSocket throws an exception if it can't listen on the specified port (for example, the port is already being used).
You're right, since you can declare transactions for every thing in Java EE they must be supported from all components you want to connect. Files if any should be stored in a database. Everything should be controlled by the container, because it the only way to have a scaling application using Java EE.
A few options:
Implement a Connector (JCA) a example is here: http://www.theserverside.com/tt/articles/article.tss?l=J2EE1_4 probably the best way if you have existing clients.
Use Java Message Queues
The relationship between this techniques is discussed here http://java.sun.com/products/jms/faq.html#relship_ejbs
Write server who stores requests in the database.(No Tx support)
If you have only one server and it seems too much overhead, you could ignore these aspects and follow Vinegars suggestion. But if you need Tx later or additional nodes this part has to be redesigned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With