File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic

Opening socket in stateless asynchronous ejb 3.1 in infinite loop.

 
Manoj Kulkarni
Greenhorn
Posts: 23
1
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic