[jboss-user] [EJB3] - Re: EJB thread not interrupted after transaction timeout

Bob Kung do-not-reply at jboss.com
Fri Apr 13 06:07:16 EDT 2012

Bob Kung [https://community.jboss.org/people/r4_1314] created the discussion

"Re: EJB thread not interrupted after transaction timeout"

To view the discussion, visit: https://community.jboss.org/message/729820#729820

So far I havn't found any elegent solution, however, I have a workaround, though it will introduces non-business code into your MDB.

1) Inject EJBContext to your MDB
2) Use ejbContext.getRollbackOnly() method to check whether the current transaction already rollback before continue process. If current transaction has been canceled, skip the following process till the end.

This solution should be safe in only database operating situation, meanwhile there still has a drawback for this solution.  Please look at the following situation. 
1) The some operations to a share resource which is not rollbackable, such as writing strings to a file in this transaction.
2) Redelivery Delay is 0 and Max Delivery Attempts more than 1
Once the transaction timeout, JMS will redeliver the message, but the previous message still on processing which is writing strings to a file. At this time, the file is operating by 2 threads and this may cause error. So it should be considered how to handle the resource conflict in this case. 

Am I missing sth? please comment.

Reply to this message by going to Community

Start a new discussion in EJB3 at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120413/f867c156/attachment.html 

More information about the jboss-user mailing list