Thread.sleep()在EJB中 [英] Thread.sleep() in an EJB

查看:97
本文介绍了Thread.sleep()在EJB中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,在EJB内部的线程混乱是一个很大的不,但是我只想就如何处理这种情况提出建议。我的EJB正在调用外部Web服务,有时可能会返回忙状态。当这种情况发生时,我想等待一段时间,然后使用与以前相同的数据重新提交请求。



什么是最好的方法来实现? / 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆