Could somebody tell us a good way of implementing the timeout for a method in a StateLess Session Bean. We tried the following ways with some problems.
Bean A ----calling a method on ------ Bean B
1. Set the Transaction timeout in the method of Bean B.
Problem : This sets the transaction as rollback after the specified timeout periods, but control doesn't return to Bean A after the time out period. The actual rollback happens only after the method in Bean B finishes. So Bean A waits until Bean B finishes. We want to stop the the execution of Bean B method after the specified timeout.
2. We called a helper component which spawned a thread and locked the starting time. It then made a call on Bean B method. After the specified time, we called the remove() on the remote interface of Bean B and called the stop() method of the helper thread.
problem : This does not have any impact on the Bean B method; although it stops the helper thread. After completing the method of Bean B, application is getting ThreadDeath exception.