wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Opening socket in stateless asynchronous ejb 3.1 in infinite loop. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply locked New topic
Author

Opening socket in stateless asynchronous ejb 3.1 in infinite loop.

Manoj Kulkarni
Greenhorn

Joined: Apr 30, 2012
Posts: 23
    
    1
Hi,

I have been reading that as per specs, EJB cannot be socket server listening on port. But I have question specific to EJB 3.1, because as per EJB3 expert group it is absolutely fine to open a serversocket to listen using EJB.
Just give your inputs on the below solution.

I create a stateless asynchronous EJB with NOT_SUPPORTED transaction attribute. In that method I used a method local variable to initiate a server socket.
I now have a while(true) loop which keeps on listening on the socket to read the message and process it and reply back.

What is wrong with this? Because as per my analysis.

There is no problem of passivation, because EJB will always be active in container till while(true) loop is broken and serversocket object is method local, so it does not clash with ejbcontext.
There is no concern of client because it is asynchronous EJB so there is no client waiting for ejb method to complete it's task
There is no problem with transaction or it's timeout because it is NOT_SUPPORTED

Let me know if there are any problems with this design and what are those?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10146
    
165

Closing this one. Please continue the discussion in the other thread you created http://www.coderanch.com/t/579566/EJB-JEE/java/Asynchronous-EJB-act-as-server

[My Blog] [JavaRanch Journal]
 
GeeCON Prague 2014
 
subject: Opening socket in stateless asynchronous ejb 3.1 in infinite loop.