-
1. Re: Calling Thread.sleep() in an EJB
frito Nov 10, 2003 2:40 AM (in response to benstarr)Well,
spec says you must not. Well, at least it is possible, but you must even know what you are doing (be familiar with the container behaviour of your server implementation!).
I would prefer a clean solution of this problem. Waiting for an asynchron task to finish can be realized with Message Driven Beans or try to use the scheduler service to start an ejb which can check from time to time if the job is done.
Greetings,
Frito -
2. Re: Calling Thread.sleep() in an EJB
benstarr Nov 10, 2003 5:00 PM (in response to benstarr)Thanks for your reply. I guess my point was that although the spec says there are other things you mustn't do with a thread it doesn't explicitly say that you can't make it sleep for a little while. I don't see how it is much different from a method that just takes a while to complete since the threading model will cause it to suspend to give time to another thread anyway. However, I am wanting to use the scheduler to send a message to a queue in another part of my application but I haven't been able to find any examples of how to do it. I believe I have to use an MBean but I'm not sure how to get a handle on the Queue. Can I just use the default initial context? Obviously this code will execute outside of the container. I know how to create an MBean invoked by a scheduler, I'm just not sure how to do the rest. Any help would be appreciated. Thanks.
-
3. Re: Calling Thread.sleep() in an EJB
benstarr Nov 10, 2003 10:33 PM (in response to benstarr)I have figured out that I can just create a scheduler that calls an MBean and then just access the Queue through JNDI as I would through a normal client (except that the JNDI namespace would not be mapped onto an ENC).
-
4. Re: Calling Thread.sleep() in an EJB
frito Nov 11, 2003 1:46 AM (in response to benstarr)Well, I don't think you have to use both, MBean and JMS.
My proposal: just use the scheduler or your own MBean. There you can do what you did in your EBJ before (thread sleep for a while and then polling for the asynchronous job to see if finished).
Greetings,
Frito -
5. Re: Calling Thread.sleep() in an EJB
benstarr Nov 11, 2003 5:45 PM (in response to benstarr)Thanks for the suggestion. Perhaps I could poll the job in the MBean and then notify a message-driven bean when it has completed or failed.