Thread.sleep()在EJB中 [英] Thread.sleep() in an EJB
问题描述
什么是最好的方法来实现? / p>
在 EJB限制常见问题它具体说明你
不应该创建或管理线程
把一个线程睡觉算作管理它。
在你的情况下,当Web服务返回忙状态时,您可以安排作业在稍后的时间点重试发送消息,例如使用 Quartz Scheduler 。执行将在那里结束,任何进一步的处理都应该被委派给作业调度程序。
I know that messing with threads inside an EJB is a big no-no, but I would just like to ask for advice on how handle this case. My EJB is calling an external Web service which may sometimes return a "busy" status. When that happens, I would like to wait for a while and then resubmit the request using the same data as before.
What would be the best way to implement this?
In the EJB restrictions FAQ it specifically states that you
should not create or manage threads
And putting a thread to sleep counts as "managing" it.
In your case, when the web service returns a "busy" status, you could schedule a job to retry sending the message at a later point in time, for instance by using the Quartz Scheduler. The execution would end there, and any further processing should be delegated to the job scheduler.
这篇关于Thread.sleep()在EJB中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!