7.1 Propagate Oracle-Tmm-Tx-Token for multiple REST API calls

When the business logic of your application spawns across multiple API calls to complete a transaction, you must propagate Oracle-Tmm-Tx-Token for multiple REST API calls.

This section explains how the Oracle_Tmm_Tx_Token token is propagated when the business logic of your application spawns across multiple API calls to complete a transaction. If you have set transactionTokenEnabled to true in the YAML file and the business logic of your application spawns across multiple API calls to complete a transaction, you must retrieve the value of Oracle_Tmm_Tx_Token and pass it in the request header for all the subsequent API calls that the user makes.

Skip these steps if the business logic of your application requires only a single API call from a user to complete the entire transaction. To understand how the Oracle_Tmm_Tx_Token token is propagated when the business logic of your application requires only a single API call from a user, see About the Oracle_Tmm_Tx_Token Transaction Token.

Let's consider a trip booking application, which requires two calls from a user. The first call is to initiate a transaction and make a provisional booking. The application requires a second API call from the user to confirm or cancel the booking. In such scenarios, when your application's business logic spawns across multiple API calls from a user to complete a single transaction, you must include Oracle_Tmm_Tx_Token in the request header of the subsequent API call from the user to confirm or cancel the booking.

The following steps describe how MicroTx creates the Oracle_Tmm_Tx_Token transaction token and propagates it for the first call and how you need to include Oracle_Tmm_Tx_Token in the subsequent API calls from a user.

  1. When a user begins a transaction, the transaction initiator service sends a request to MicroTx.
  2. MicroTx responds to the transaction initiator and returns Oracle_Tmm_Tx_Token in the response header.

    The MicroTx library creates this token based on the private-public key pair that you provide. You don't have to create the Oracle_Tmm_Tx_Token transaction token or pass it in the request header.

    MicroTx works with multiple headers and token. For the sake of simplicity, we are limiting our discussion to the Oracle_Tmm_Tx_Token transaction token in this section.

  3. To secure calls from the participant services to the transaction coordinator, the MicroTx library passes Oracle_Tmm_Tx_Token in the request header for all the subsequent calls.
  4. MicroTx returns Oracle_Tmm_Tx_Token in the response header while responding to the first call from the user. Retrieve the value of Oracle_Tmm_Tx_Token from the response header.
  5. In all the subsequent API calls that the user makes, you must manually include the Oracle_Tmm_Tx_Token in the request header. Provide the value that you have retrieved in the previous step.

This ensures that the multiple API calls from a user are linked together and all the calls are considered as part of a single transaction.