Wednesday 22 August 2012

Websphere Process Server Transaction Management

This post is trying to shed some light on transaction management in Websphere Process Server.
IBM has participated the release of OASIS standard WS-Transaction 1.1 which introduces two models of transactions WS-AT (Atomic Transaction) and WS-BA (Business Activity).

WS-AT is a standard of establishing and coordinating a global transaction between resources managers so that they'all commit or rollback together. WS-AT specifies that transaction participants have to implement 2PC (2 phases commit) algorithm.
2PC algorithm defines a global transaction to encompass 2 phases:
A. Request to commit that is being issued by Transaction Coordinator; when resource manager allocates resources and become ready it replies with ready status; when Coordinator receives readiness messages from all resources managers it enters Commit phase when it  sends to all resources managers a commit request.
B. Commit phase: All resources managers commit together or release resources without committing together.
Websphere Application Server version 6.0 complies with WS-AT 1.1 and implements JTA (Java Transaction API) interface.
Developers of J2EE, WESB and WPS modules should not be concerned JTA, because it is enabled through  deployment descriptors.
A web service may have policy set assignment that implies the support of WS-AT.
First step in considering mediation or business process translatability aspect is to ensure that resources managers that capable of importing global transaction; For instance database vendor must comply with XA standard and hence WAS JDBC adapter can be configured to enable XA. Also JCA's vendor should be ready to import global transaction. For instance Websphere SAP adapter supports global transaction. Also web services need to be confirmed complying with Policy-Set than include WS-AT. These web services could be  the interface of another business process that resides in different runtime inside SOA solution or even JAX web service.
What would happen if any of these resources is not capable of importing global transaction? Process engine would commit before the invocation activity and it will not participate the transaction.
Micro-flows are by default running in one transaction. BPEL engine will take care of coordinating global.
LRBP (Long running business processes) by default runs each activity in a separate transaction. Of course this behaviour can be changed by changing the activity transaction property to 'Participate' instead of 'Commit Before' or 'Commit After'. Nevertheless there are transaction boundaries that are enforced:
- Boundary before invoke activity of asynchronous web service to prevent deadlocks.
- Initiation invoke of Human Task (It is async by default).
- Before Wait activity.
Hence global transaction can also be established inside LRBP that spans multiple activities.
Question: How Transaction management can be achieved when a business process encompasses Wait,Human Tasks and async calls? The answer is through WS-BA.

WS-BA is a compensation transaction management model that basically used to coordinate transactions between loosely coupled components. In other words, components will commit transactions immediately in only one phase but will expose compensation handler interface to rollback committed transactions.
Business Activity context is propagated in Web service messages by using the standard specifications.
Thinking as of a web service, com.ibm.websphere.wsba.CompensationHandler interface should be implemented and configured in the deployment descriptor.
Thinking as of business process, Consider compensation handler in BPEL will pack WS-BA configuration in the EAR.

1 comment: