• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

SF Session bean threading

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have a question about creating a thread in a SF bean.
I want to create a stateful session bean which implements a start methodes that creates a thread which read's some data from a database.
I've read some documentation on this subject, and that tell's me the use of thread's in EJB's is not advisable. But that's about all about this subject.
Are there are some points which require special attention or be cautious about?
I hope someone can help me with this issue.
Regards,
velli
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Creating threads willy-nilly in EJBs is a BIG no-no. It could dramatically affect the performance and stability of your application in a negative way. However, since you haven't actually detailed what you are trying to accomplish, it is hard to help much.
It would be helpful if you explained the problem that you are trying to solve and maybe we could suggest a solution more appropriate for use with EJBs.
 
velli fieldman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
O.k more information, here we go:
The problem is the following:
I need to create large reports of sales figures from a database and convert them to xml for viewing in a intranet environment (stored in database).
So what i want to do, it to create a stateful bean which can start, stop, suspend en resume and preview the creation of a xml document.
One of my problems is that the generation takes lot's of time (hours) and therefore i want to be able to remotely manage these jobs.
Maybe preformance degradation is not the biggest issue since there won't be many users. (Actually problably only one) I figure, A report running 10 minutes longer won't make so much difference when they already run for a few hours.
What i'm worried about, is strange or inconsistent behaviour. But my expertise is just to thin to make a good judgement about this, so therefore i really appriciate your help.
Best Regards,
velli.
 
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IMHO, this does not sound like a job for EJB. Why did you choose EJB for this?
 
velli fieldman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the idea is that i can make a web interface so that i can administrate from home. Other considerations, JDBC connection pooling, write once, deploy anywhere.
Also i want to try to provide some kind of failover, in case something goes wrong it won't have to start all over again. In Jboss Stateful session beans provide failover by replication.
(I made a test for this and it works. The report can be retrieved after a server crash.) Of course, I could also write the report to disk periodically.
I guess it's not good j2ee design. Anyway I find it hard to decide what the best solution for a problem is because they all seem to have their disadvantages. I'm really curious to your opions on this issue.
 
Chris Mathews
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by velli fieldman:
One of my problems is that the generation takes lot's of time (hours) and therefore i want to be able to remotely manage these jobs.


This seems like the perfect situation to use asynchronous processing. Fire off a JMS Message to Queue and have an MDB pick it up and run your report, therefore the client isn't blocking for a response and you don't have to restort to creating threads.
 
Ranch Hand
Posts: 8946
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may help
http://www.javaworld.com/javaworld/jw-07-2003/jw-0718-mdb.html
 
Ranch Hand
Posts: 1327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can one stateful session bean control and create another stateful session bean? and the first statful session bean is a session facade
that one session facade is created by the service locator which is used by business delegate
are all that possible?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, stateful session beans can have references to other stateful session beans (as well as any other type of beans).
 
Billy Tsai
Ranch Hand
Posts: 1327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but the referenced stateful session bean has to be created by service locator? because it will reference other entity beans as well which will also make it into a session facade
so there will be like two session facade
???
please tell if thats right and possible
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whether or not the session bean is a facade, it can have references to other session beans and entity beans. It doesn't matter whether the session bean locates these references directly from JNDI or from a service locator.
reply
    Bookmark Topic Watch Topic
  • New Topic