开发者

Ejb 2.1 Timer IOException

I have a weird problem, I am using EJB 2.1 timer object to fire a timer at a specific time in a day and do some housekeeping stuff like deleting files. The timer开发者_如何学Python fires as expected but the problem is that it does not stop. Following is the code I used to initiate the timer:

Timer myTimer = timerService.createTimer(timeOfDay, myInterval, null);

In my ejbTimeout method I have a code which deletes files, now if I get a IOException in this method then the EJB is rolled back; and the method is called again. The timer fires 10-15 times before stopping. I am using WAS 6.1 and I had some bad experiences with WAS not adhering to EJB specks before. Does anybody have any other explanation or justification ? any help would be appreciated !


Instead of writing logic inside TimeOut method, use threads to delete the files. So even if exception occurs in thread, your transaction may not get rolled back.

Else you can use Bean Managed Transaction to have control over transactions, can rollback - commit accordingly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜