7.14.7.5 TmmStart Function
Enlists the transaction participant service with the MicroTx XA coordinator in a global transaction, starts the XA transaction boundary, registers the call back REST APIs, and returns the transaction metadata.
Syntax
TmmStart (
callBackUrl IN VARCHAR2,
linkUrl IN VARCHAR2,
requestId IN VARCHAR2,
authorizationToken IN VARCHAR2,
tmmTxToken IN VARCHAR2)
RETURN TmmReturn;
TmmStart Function Parameters
Parameter | Description |
---|---|
callBackUrl |
Mandatory. Enter the URL of your participant service and suffix it with the name of the ORDS REST module. MicroTx uses the URL that you provide to connect to the participant ORDS service. For example, |
linkUrl |
Mandatory. |
requestId |
Mandatory. A unique ID to trace a transaction across microservices. |
authorizationToken |
Mandatory.
If you have enabled authorization by setting |
tmmTxToken |
Mandatory.
If you have set |
Return Value
The TmmStart
function returns a TmmReturn
object, which has the transaction metadata. The TmmReturn
object has an attribute, proceed
, which indicates whether the TmmStart
function was successfully executed and whether the transaction can progress.
TmmReturn.proceed value
|
Indicates that... |
---|---|
0 | the TmmStart function was called within an XA transaction, but the XA initialization was not successful. So the application code must not proceed with the XA transaction.
|
1 | the TmmStart function was called within an XA transaction and the XA initialization was successful. So the application code must proceed with the XA transaction.
|
2 | there is no MicroTx XA transaction and the function has been executed within a local transaction. So the application code should proceed as normal. |
Examples
The following sample code snippet demonstrates how you can call the TmmStart
function and pass values to it. It returns a MicroTxTransaction
object.
..
//In the example callback URL below, account is the name of the ORDS REST module.
l_callBackUrl VARCHAR2(256) := get_microtx_config(''callback-url'') || ''/accounts'';
//Call the TmmStart function to initiate the transaction. Pass the parameters, other than callBackUrl, as shown in the example below.
l_microTxTransaction := TmmStart(callBackUrl => l_callBackUrl, linkUrl => :linkUrl, requestId => :requestId, authorizationToken => :authorization, tmmTxToken => :tmmTxToken);
//Check if the transaction should proceed or not
IF (l_microTxTransaction.proceed > 0) THEN
//Run the application's business logic
...
END IF;
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