Using timeouts with transactions

There are situations where the time used to execute a transaction takes too long. This can result in unresponsive applications or the appearance that the application has locked up. To control this behavioral aspect of transaction we need to limit the amount of time allocated to a transaction. In this recipe, we will address how this is done.

Getting ready

Using timeouts involves:

  1. Determining whether a timeout period is needed
  2. Determining what that period should be
  3. Using the setTransactionTimeout method in the case of BMT

    Determining whether timeouts should occur or what the timeout period should be is application-specific. As a result we will not address the first two steps here.

    If it is a CMT, we can use the container ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.