Friday, December 17, 2010

Transactions from within a Process Flow

Using JDBC Adapter 6.5, patch 23 in IS 7.1.3 we were having an issue where a flow service that inserts data in to 3 tables (each table insert via a JDBC Adapter service) does not roll back properly on a failure when called from within a process flow.

When run from within Developer, it would work fine and would roll back as you would expect.  As soon as we called it on the "Save to Database" step in our process, it would no longer roll back.

Trying XA_TRANSACTION and LOCAL_TRANSACTION as the transaction type on the JDBC Connector does not make a difference.
Basically, we were getting auto commit on each insert when the flow service is invoked from a Process Model.

In reviewing the logs, we see that

When the Process starts, a "Beginning transaction" is logged.
When the Process finishes, a "Committing transaction" is logged.
The process always does a commit - even when my IS flow service Exits $flow with FAILURE


We were not able to do Explicit transaction management because the JDBC Adapter Services were using a JDBC Adapter connection that was already in the parent transaction context. I needed to create a new JDBC Adapter connection (in IS) and change my JDBC Adapter Services to use the new connection. Then I could explicitly call startTransaction and or commitTransaction/rollbackTransaction in my flow service.

Hope this helps others.  Thanks to Brian for figuring this out!

No comments:

Post a Comment