• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doing IO operations in a Session Bean

 
Savio River
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Is it possible to do a getInputStream and getOuputStream of bytes in a Session Bean..
My Client is an Applet, I have a Servlet in between Applet and session bean, Now my session Beans does a lot of processing and I would like to get the status of its progress to the client, for this I have open a Stream from the Applet..
Do u think this is posible, pls let me know if there is another way..
Thanks
Savio
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider a callback Session bean. When you fire up the "workhorse", pass the callback SB in and have the workhorse post progress to it. Then you can have your applet periodically query the callback SB.
That being said, I don't recommend using EJBs as long-running process entities. You can't spawn threads in them, you shouldn't do I/O in them and HTTP clients won't operate the way you want, since the HTTP request isn't resolved until you return from both the bean and from any intermediary logic (e.g. servlet/JSP).
A more effective approach is to create an "engine" process(es) that runs under its own thread(s) and queue up requests that come in. You can use either standard JavaBeans or EJBs to track the work requests.
 
Savio River
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim,
If I have to use a callback session bean , I will have to do a look up for each progress of the process which is quite an overhead....Am I right !!
A more effective approach which u had suggested to Queue up requests ....
But in my application my EJB Session Bean dispathches a lot of records to another process.. and it takes atleast 3 hrs so I have to send some sort of a Status to the client..
[ February 22, 2003: Message edited by: Savio River ]
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, any process that takes 3 hours I would definitely not want to put in an EJB. I'm sure I could think of other reasons, given time, but a very good one would be that it could delay server shutdowns up to 3 hours - and EJB just isn't expected to be an interruptable process.
Something that long-running you wouldn't want to tie up the client's computer with a progress monitor anyhow. However they would appreciate a "dashboard" they could look at periodically. The dashboard could either query the process server directly via the callback bean technique I mentioned before. As to the overhead, it's mostly dependent on how often you want to query.
It's not uncommon for really long-running processes to spawn an e-mail notification when they're done. That way the user isn't sitting around waiting on things, but will find a notification whenever they are ready to deal with the results.
 
Savio River
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim, thats a very satisfactory answer, I will be trying out something like that
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic