-
1. Re: Transaction timeout question
jhalliday Apr 16, 2008 4:59 AM (in response to rotula)> Is this any way to interrupt the execution method?
The transaction system won't do that for you. You need to build a timeout into the web services call if you want such behavior.
Transaction timeouts happen in a background thread. The timeout will occur even if your thread is blocked. It just won't be evident to your business logic until it resumes. -
2. Re: Transaction timeout question
rotula Apr 16, 2008 8:36 AM (in response to rotula)According your answer:
The timeout will occur even if your thread is blocked.
this piece of code should run:@Stateless public class SomeBean{ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) @TransactionTimeout(value=100) public void methodA(){ methodB(); } @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) @TransactionTimeout(value=10) public void methodB(){ Thread.sleep( 20000 ); // sleep for 20 sec. } }
but it doesn't.
methodB should timeout after 10 sec according TransactionTimeout parameter.
So, can a timeout occur on methodA without wainting for methodB to resume? -
3. Re: Transaction timeout question
adinn Apr 16, 2008 10:13 AM (in response to rotula)What Jonathan said was perfectly correct. The point you have failed to grasp was explained in the previous answer
> > Is this any way to interrupt the execution method?
> The transaction system won't do that for you.
So, the container is doing what you were told it would do i.e. it is cancelling the transaction when the timeout is reached. It is not doing what you were told it would not do i.e. it is not interrupting your blocked thread.
When your thread wakes up and tries to perform some activity in the transaction it will discover that the TX is no longer active. If you want to wake the thread up earlier then arrange for that to happen by some other means. -
4. Re: Transaction timeout question
rotula Apr 18, 2008 1:13 AM (in response to rotula)Thank you both for your answers!
Unfortunate I messed up my transaction example with another blocked thread.
Forget it! What I really intend to simulate was a long process. Did it change the problem now?
I mean, we run on same thread, we process a long job, didn't the transaction system
timeout from methodB - which is marked as "RequiresNew" - and continue with remaining part of methodA instead?
Again, imho, a business method - belongs to a CMP bean -running on a new transaction context with a
fixed allocated space of time should interrupt his execution after reaching timeout. Or?