Discussion:
[jboss-user] [IronJacamar] - Is this the right project for a simple socket usecase?
kaffeetrinker
2013-06-04 09:46:24 UTC
Permalink
kaffeetrinker [https://community.jboss.org/people/kaffeetrinker] created the discussion

"Is this the right project for a simple socket usecase?"

To view the discussion, visit: https://community.jboss.org/message/821211#821211

--------------------------------------------------------------
Hi there,

i stumbled over iron jacamar while searching for jca, but I'm not very familiar with jcaeither. I have a simple usecase:

The j2ee web project I'm working on needs to connect to a tcp socket, send/receive data and then close it. I could have done this within a singleton bean, but because I have to watch the socket inputstream, I have the need to create a thread for that. That said, I think it is not allowed to create threads within a j2ee container on my own. I also tried to use @Asynchronous for the socket function, but that resulted in multiple concurrence exceptions.

Now that i've read a little bit about jca and iron jacamar, I think maybe this is the right way to implement the socket connection. But for example, I could not find a sample with a while loop over the socket, that would notify my web project in case of an event.

Could you give me some hints what to use? So far I thought of creating an outbound jca (with the help of the eclipse plugin) and send event notifications to the web app via jms queue (because I could not find a sample of how to notify the resource client in case of an event).

Thank you!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/821211#821211]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
Jesper Pedersen
2013-06-04 11:30:22 UTC
Permalink
Jesper Pedersen [https://community.jboss.org/people/jesper.pedersen] created the discussion

"Re: Is this the right project for a simple socket usecase?"

To view the discussion, visit: https://community.jboss.org/message/821229#821229

--------------------------------------------------------------
JCA is correct for your use-case.

See http://www.ironjacamar.org/doc/userguide/1.1/en-US/html/ch01.html#overview http://www.ironjacamar.org/doc/userguide/1.1/en-US/html/ch01.html#overview for an overview of the architecture. In your case the Socket will be in the ManagedConnection. You can checkout our HelloWorld example at http://www.ironjacamar.org/doc/userguide/1.1/en-US/html/apb.html#sample_helloworld http://www.ironjacamar.org/doc/userguide/1.1/en-US/html/apb.html#sample_helloworld or in the IronJacamar distribution.

And yes, if you need a Thread you will use the WorkManager with your Work implementation.

If you are doing inbound then you will need a MessageEndpoint/MessageEndpointFactory that supports your listener. I would suggest supporting the JMS listener such that you can use the EJB3/MDB container as the MessageEndpoint/MessageEndpointFactory. You could do your own of course. There is an inflow example here: https://github.com/ironjacamar/ironjacamar/blob/master/core/src/test/java/org/jboss/jca/core/inflow/PureInflowTestCase.java https://github.com/ironjacamar/ironjacamar/blob/master/core/src/test/java/org/jboss/jca/core/inflow/PureInflowTestCase.java

Likely you are looking for something more simple though.

I'm not saying that JCA is the only solution to the problem - you could likely hack something together with Netty - but from a pure EE perspective I would say JCA is the way forward.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/821229#821229]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]
Loading...