Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

Opening socket in stateless asynchronous ejb 3.1 in infinite loop.

Manoj Kulkarni
Posts: 23
  • Mark post as helpful
  • send pies
  • Report post to moderator

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
Posts: 10444
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Closing this one. Please continue the discussion in the other thread you created
    Bookmark Topic Watch Topic
  • New Topic