Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

socket access from ejb  RSS feed

 
Mark Lybarger
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is currently a server type app that polls a database looking for orders to process, and if it finds orders, it creates an xml document, opens a socket , writes the xml to the socket, and gets the response from the person on the other side.
it's being investigated to migrate the app to an ejb so that instead of database polling, someone can just call the app to process an order. i've read that socket stuff in ejb is frowned upon if not explicitly disalowed.
so, i thought i'd ask the experts what specifially about sockets is not aloud and if this usage is ok. the app doesn't use the ServerSocket, but uses the Socket class. it connects to the socket as:

the guy listening on that socket on the other end is a c application that forwards the data off to an external party. the app reads the reponse from the socket using:

any suggestions on this type of usage from a stateless session ejb would be most welcome. also, some reading material would be nice too . thanks
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In short... listening on a socket is forbidden by the ejb specification. However, writing to a socket is just fine.
The exact wording from Section 24.1.2 of the EJB 2.0 Specification is:
An enterprise bean must not attempt to listen on a socket, accept connections on a socket, or use a socket for multicast.
 
Mark Lybarger
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the response!
so, is getting an inputStream from a socket, and reading from a socket the same as listening to a socket?
i've read other places (possibly here) suggestions of using a socket server to access a socket and let it do the "listening" and writing. is there a document on how this would be accomplished? and perhaps any freely available socket servers?
since i'm not familiar with the definition of "listening" and reading, is the code that i posted prohibited in an ejb?
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Lybarger:
since i'm not familiar with the definition of "listening" and reading, is the code that i posted prohibited in an ejb?

Your code is fine. As long as your code is not creating SocketServers and listening for client requests then you are fine.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Lybarger:
there is currently a server type app that polls a database looking for orders to process, and if it finds orders, it creates an xml document, opens a socket , writes the xml to the socket, and gets the response from the person on the other side.
it's being investigated to migrate the app to an ejb so that instead of database polling, someone can just call the app to process an order. i've read that socket stuff in ejb is frowned upon if not explicitly disalowed.
any suggestions on this type of usage from a stateless session ejb would be most welcome. also, some reading material would be nice too . thanks

Hi Mark,
I am also working on a similar prototype application.
But I have the foll. constraints.....
1. The third party Socket server that listens for connections from my SLSB socket client cannot accept more than 5 connections.
Sometimes the database table could be filled up with a 1000 new records.
The Container might create more than 5 connections (may a few hundread SLSB beans) to process the new records at the same time. Not sure about this.
How do I restrict the Container to use less number of SLSBs in my application? Is there an vendor specific parameter to control this?
Moreover the Socket client-server handshake is a blocking call for the calling client application, which happens to be a servlet in my case.
I was wondering if you happen to have or overcome any of these similar issues in ur application... :roll:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!