Kiran,
Explicit transations are very useful when you don’t want the default transaction management, for instance to start and end several separate transactions within a service; or to have rollbacks controlled by application logic rather than server errors.
The pattern I tend to use for explicit transaction management is as follows:
startTransaction
TRY
do stuff
commitTransaction
CATCH
getLastError
rollbackTransaction
report error
If your transaction only impacts on a single database, LOCAL_TRANSACTION is adequate for your connection. If, however, you want the transaction to span multiple databases, use XA_TRANSACTION, so that they all are committed or rolled back together.
Some notes from our experiences:
-
The transaction name can be anything you like. We never assign a name – we just use the one generated and returned by startTransaction.
-
Be aware that if a calling service has already started a transaction, the IS may throw an error when you try to start another one in the current service – so make a design decision about where the transactions are to be controlled.
-
Because of the way that distributed transaction work, in a multi-DB transaction, one (and only one) of the DBs can actually be configured as LOCAL_TRANSACTION. If more that one is defined as LOCAL_TRANSACTION, you may find that changes fail to commit (but no error message may appear).
-
For some reason, while a DB connection is defined as XA_TRANSACTION, you cannot build “batch” services such as BatchInsertSql. You will need to temporarily downgrade the connection to LOCAL_TRANSACTION while you create the service. Don’t forget to change it back afterwards.
-
Explicit transactions do not work in Trace or Step mode, as the server commits after every step. We have found this can mess up the server threads and connections, forcing a server restart, so we have defined wrapper services called (surprisingly) “startTransaction”, “commitTransaction”, and “rollbackTransaction” that check if they’re running in Trace or Step mode prior to calling the ART transaction services. This is easier and safer than manually disabling transactions when we want to trace something.
Hope this helps,
Michael.
#webMethods#Adapters-and-E-Standards#Integration-Server-and-ESB