Java Reference
In-Depth Information
now in an invalid state that will require intervention. A HeuristicRollbackExcep-
tion is thrown when a heuristic decision is made and all of the resources have been rolled
back. With this exception, the client should resubmit the request. These exceptions need to
be caught and handled by the application.
One important thing to remember is that failures can happen on any end. The container
with the transaction manager may fail (system shutdown), leaving the resource managers
hanging. In this case, the individual resource managers may make a decision on their own
to roll back—they can't keep resources locked forever. When the transaction manager
comes back up, it'll attempt to complete the transaction.
6.1.7. JTA performance
JTA is designed to perform optimally whether you're using a single resource or a dozen.
There are a number of common optimizations that are implemented by every transaction
manager. These optimizations help ensure that JTA won't be a bottleneck for your applica-
tion. These optimizations can be summarized as one-phase, presumed abort, and read-only.
In the previous section we discussed how a two-phase commit is implemented. A two-
phase commit is needed for situations in which two or more resources are participating in
a transaction. But if only one resource is being used, the transaction manager will use only
a single commit phase. The voting phase will be skipped, because it serves no purpose in
this situation.
One or more resources may choose to abort during the voting phase. When this occurs, it
no longer makes sense to poll the other resource managers. Once a rollback has been detec-
ted, the transaction manager will immediately notify resource managers that haven't been
polled to roll back. There's no sense in asking these resource managers for their commit/
rollback decision because their response is irrelevant.
Resources that are read-only and didn't update any data don't need to take part in the com-
mit process. A resource manager will report to the transaction manager that it doesn't have
any changes to commit. The transaction manager will then skip over the resource during
the voting and commit phase, thus eliminating several extra steps.
Search WWH ::




Custom Search