Roll Back Issue

Hi.

I have several services that insert/update records on tables.

Each of these services (A,B,C) have the following structure:

1.StartTransaction (store in localVariable)
2.Try
2.1 Logic
2.2 CommitTransaction (localVariable)
3.Catch
3.1 Logic
3.2 RollbackTransaction (localVariable)

The services work ok, so far so good… :smiley:

But now I need another service that needs to call several of these services

Main Service
1.StartTransaction (store in lVariable)
2.Try
2.1 call service A
2.2 call service B
2.3 call service C
2.4 CommitTransaction (lVariable)
3.Catch
3.1 Error Logic
3.2 RollbackTransaction (lVariable)

My issue here is that if any of the services A, B or C fails, the main service should rollback without commiting anything to the DB.

What is actually happening is that when service B fails, the main service rollbacks but changes made by A are already commited and do not rollback! :angry:

That’s correct because a commit is being done in A.

Don’t do start, commit and Rollback in services A,B and C.

In your parent/Main service do start, commit and rollback.
Thus if service B fails the insertion/updation done by service A will be rollbacked.

Commit your transaction in Parent service after the completion of service A,B and C.

The issue is that services A, B and C can be called from CAF and require that either all logic is done or everything is rolled back. So I need commit and rollback in services A, B and C…

:confused:

What I have done is to add an input variable to the A, B and C services that enable the transactions or not. This will allow the services to be called independently with transactions or by the Main service without using transactions inside.

The flow runs trough all A, B and C and the main commit returns the error:

AuditLogManager Exception: java.lang.NullPointerException
commit failed: more than 1 local trans enlisted. xid = [FormatId=45744, GlobalId=/1286811217265, BranchQual=1] rxid = {2}
delisted transaction commit failed: java.lang.IllegalStateException: commit failed. more than one local transaction enlisted. xid = /1286811217265
Adapter Runtime: Error Logged. See Error log for details. Error: [ART.114.303] Adapter Runtime (Transaction): Unable to commit transaction.
Adapter Runtime (Adapter Service): Error(s) occurred while closing adapter connections.

:eek:

The rollback runs ok. :lame:

Are A, B and C all using the same connection pool? If not, then that’s the issue. Only one connection in a transaction can be LOCAL_TRANSACTION. The others need to be XA_TRANSACTION.

Thanks!!!

XA Transactions do solve the nested transaction issue.