7.14.7.1 TMM_BEGIN_TX Function
Used by a transaction initiator application to start a global transaction that spans across multiple microservices. It returns a MicroTxTransaction
object which has the transaction metadata.
Syntax
TMM_BEGIN_TX ( forwardHeaders IN ForwardHeaders DEFAULT NULL, transaction_timeout IN NUMBER) RETURN MicroTxTransaction;
TMM_BEGIN_TX Function Parameters
Parameter | Description |
---|---|
forwardHeaders |
Optional. The application forwards the specified headers to the MicroTx coordinator, and then the coordinator uses these headers while communicating with the application. An application can forward the following headers: authorization token, transaction token, and a unique ID to trace the transaction across the microservices. If you have enabled authorization by setting If you have set |
transaction_timeout |
Optional. Specify the amount of time, in milliseconds, for which the transaction remains active. If a transaction is not committed or rolled back within the specified time period, the transaction is rolled back. The default value and minimum value is 60000. This overrides the value of xa-transaction-timeout in the microtx_config table.
|
Return Values
Parameter | Description |
---|---|
MicroTxTransaction |
Returns the transaction object |
Examples
The following sample code demonstrates how you can pass the forward headers to the tmm_begin_tx
function and the function returns a MicroTxTransaction
object.
//Set the headers that you want the application to forward to MicroTx
l_forwardheaders := ForwardHeaders(:authorization, :tmmTxToken, :requestId);
//Call the TMM_BEGIN_TX function to initiate the transaction
l_microTxTransaction := TMM_BEGIN_TX(l_forwardheaders);
Note down the name of the returned value as you will provide this later to get the transaction status, commit or roll back the transaction.
Parent topic: MicroTx PL/SQL Library Functions