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
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.
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.
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.
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.
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?
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
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.