• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doing IO operations in a Session Bean

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim, thats a very satisfactory answer, I will be trying out something like that
 
I knew that guy would be trouble! Thanks tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic