A question on local transaction

Hi All,
As we know we do ‘LocalTransaction’ by default autoCommit → Off and ‘NoTransaction’ by default autoCommit ->On.

I wrote a flow service which has one adapter service which is using insert statement which makes use of ‘LocalTransaction’ and after the execution i can see that record is getting executed into the DB.

I wrote a flow service which has 2 adapter services which make use of ‘LocalTransaction’ and have insert operation as part of those. After running the service I can see both services inserted records into the DB.

How does it make difference from ‘NoTransaction’ if they are commiting the transactions without explicit commit.

Kindly share your views after doing a little R&D on this and many thanks for your time.

Thanks,
Ravee.

Can someone shed light on this ?

Thanks,
Ravee.

For your scenario, the transactions are managed by built-in J2EE-based Transaction Manager.

If you want to explicitly handle transactions use start, commit and rollback transactions.

You must understand the concept of implicit and explicit transactions. In your scenario make the 1st adapter service success and 2nd adapter service to fail and see what is the behavior?

Ravee,

As Mahesh implied, the difference becomes noticeable when an error occurs. In the NO_TRANSACTION scenario, if an error occurs any time after the adapter service was already successfully invoked, the transaction does NOT get rolled back. In your case, you will still see the data in the database. In the LOCAL_TRANSACTION scenario, the transaction will get rolled back (i.e., you will not see the data in the database). This is true whether you have one adapter service call, two, or one hundred.

Just play with it by adding an “EXIT and signal failure” step to your service.

Percio

1 Like

Are you running the service, which contain transaction handling, as a whole or are you stepping through it (i.e. for debugging)?

In the second case the transaction handling will not work and you will see some messages in the server log and error log abou this (“already used in another transaction” or similar).

In the first case please share you flow implementation as a screenshot so we can check where the Transaction Handling fails.

Regards,
Holger

as mentioned by Percio, if you are using “EXIT and signal failure” then only it will roll back the entire block of successful operations performed before the failed adapter service using the same local transaction. if you don’t use “EXIT and signal failure”, it will behave as NO Transaction