|
Recovery:
One of the most important aspects that characterize a
transaction system is the ability of the system to recover from
a failure or a crash. The recovery process can be very
complicated depending on the complexity of the system and the
importance of the data in question. Most systems at least strive
to get the system back to the best consistent state just before
the crash. JTA systems guarantee that in the event of a failure,
transactions that were midway during the crash are either
committed or rolled back so that states are consistent. The
system must have sufficient persistent information stored
somewhere so that it can make decisions on whether to commit or
rollback when the system is back in action.
The J2EE activity specification does not provide or force
specific recovery and persistence mechanisms. It just defines
the requirements for recovery and persistence of activity data
in the event of a failure. It is left to the implementers to
determine a feasible solution based on the requirements. Since
most of the extended transactions could span multiple systems,
the HLS and the Activity service for each could be different.
The recovery process is the shared responsibility of the HLS and
activity managers of the individual systems to perform their
part of the recovery. The actual implementation of the recovery
may be completely different in each of the systems, but they
need to make sure the shared services are portable across all
the systems.
For the recovery to be possible it needs the state data that
was persisted before the crash so that it can make the system
consistent according to the old state. The responsibility to
decide the frequency and time to persist the state of all the
participants falls on the HLS. When the HLS decides to make an
activity persistent, it calls the setPersistent method of the
ActivityCoordinator to make the activity persistent. The HLS has
to record the state of Actions, SignalSets and PropertyGroups
that are registered with the ActivityCoordinator. When a
recovery needs to be done, the HLS calls the User-Activity
recreate method of the ActivityCoordinator to recover
SignalSets, PropertyGroups and Actions and then recreates the
activity. It also needs to reestablish the context hierarchies
for the activity. The HLS then performs processing on the
activities to complete them.
Completion and Timeout:
In extended transactions like these where smaller transaction
units work independent of each other there is always a danger of
one or more transactions holding off the whole extended
transaction for a long time. This needs a policy on how long a
wait is acceptable before the whole extended transaction needs
to be timed out. In case of timing out care needs to be taken to
clean-up the resources being held for a long time and roll back
the transaction when required.
A timeout period can be specified on each activity using the
UserActivity interface. The ActivityContext passes the timeout
for an activity to other environments where the activity is
active. In case of a failure that is being recovered the HLS can
direct completion of an activity if it is a root activity.
However if the activity is a sub-activity then the HLS has the
responsibility to reconnect to the parent of this activity and
restore it to the state it was before the failure. In case
the parent activity is not available or cannot be connected to
the HLS, it can choose to complete the activity heuristically by
invoking the heuristicComplete method of the
ActivityCoordinator.
Conclusion:
The J2EE Activity service for extended transactions can be seen
as an extension of JTA to satisfy needs that are not met by JTA.
It leverages on the concepts already in J2EE used in JTA, EJB
and the JDBC specifications. The activity service is packaged in
the J2EE platform as an extension package "javax.activity". At
the time of writing this article, there doesn’t seem to be a lot
of vendors supporting this specification. Probably application
vendors are still waiting for the final approval on the Java
Specification Request (JSR 95) before they start supporting the
specification. The demand for J2EE activity service is bound to
grow as more industries wire themselves and expect systems that
support extended transactions.
Benoy Jose is a web developer with over six years of experience in J2EE and Microsoft technologies. He is a Sun Cetified programmer and enjoys writing technical and non-technical articles for various magazines.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|