6.10.1 Configure Library Properties for Spring REST Apps

Provide configuration information for the MicroTx library properties for every Spring REST application. The property values that you must provide would vary depending on whether the application is a participant or an initiator.

Provide property values for the MicroTx library in the application.yaml file.

  • spring.microtx.coordinator-url: Enter the URL to access the MicroTx coordinator. See Access MicroTx. You must enter this value for the transaction initiator application. You don't have to specify this value for the transaction participant applications.

  • spring.microtx.participant-url: Enter the URL of your participant service. MicroTx uses the URL that you provide to connect to the participant service. Provide this value in the following format:
    https://externalHostnameOfApp:externalPortOfApp/
    https://externalHostnameOfApp:externalPortOfApp/
    Where,
    • externalHostnameOfApp: The external host name of your initiator or participant service. For example, bookTicket-app.
    • externalPortOfApp: The port number over which you can access your participant service remotely. For example, 8081.
    You must specify this value for the transaction participant applications. You don't have to specify this value for the transaction initiator application.

    For example, https://bookTicket-app:8081.

  • spring.microtx.propagation-active: Set this to true when you want to trace the transaction from end-to-end. This propagates the trace headers for all incoming and outgoing requests.

  • spring.microtx.http-client-connection-pool-size: Enter the number of connections to the MicroTx library to MicroTx. The default and minimum number of connections is 10. The maximum value is 20. You can change this value depending on the number of queries that your services run. Specify this value for both initiator and participant applications.

  • spring.microtx.xa-transaction-timeout: Specify the maximum 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. Specify this value for both initiator and participant applications.
  • spring.microtx.xa-resource-manager-id: Specify a unique string value for each resource manager that you use in the XA transaction. The unique value that you provide as RMID is used by MicroTx to identify the resource manager. If more than one participant uses the same resource manager, then specify the same resource manager ID for the participants that share a resource manager. This value is not related to any properties of the data store. For example, 174A5FF2-D8B2-47B0-AF09-DA5AFECA2F71.
  • spring.microtx.xa-xa-support: Set this to true when you use XA-compliant resources. Set this to false only for the single transaction participant service that uses a non-XA resource. The default value is true. When xa-xa-support is set to true, the values set for xa-llr-support and xa-lrc-support are ignored.
  • spring.microtx.xa-llr-support: Set this to true to enable the Logging Last Resource (LLR) optimization. Set this value only for the transaction participant service that uses a non-XA resource as a resource manager. The default value is false. When xa-llr-support is set to true, the value set for xa-lrc-support is ignored.

    Only when you set this property value to true, you can also specify a value for the xa-llr-delete-commit-record-interval property. Specify the maximum amount of time, in milliseconds, for which the committed records are retained. The default value is 7,200,000 ms or 2 hours. Before performing a local commit, the transaction coordinator creates a commit record in the LLR branch. The commit records are deleted after the time period specified in the xa-llr-delete-commit-record-interval property. Specify this value only for the service that uses a non-XA resource as a resource manager.

  • spring.microtx.xa-lrc-support: Set this to true to enable the Last Resource Commit (LRC) optimization. Set this value only for the transaction participant service that uses a non-XA resource as a resource manager. The default value is false.
  • spring.microtx.xa-promotable-active: Set this to true to enable local transactions or to manage certain transactions locally without involving the coordinator. Specify this value only for a transaction initiator service that also participates in the transaction.

    The default value is false. If you set the value of xa-promotable-active as false, every transaction starts as a global transaction by default and it is associated with a GTRID. A local transaction is not initiated. See About Global and Local Transactions.

  • spring.microtx.xa-rac-active: Set this to true only for the transaction participant service that uses an Oracle Real Application Clusters (RAC) database as a resource manager. The default value is false.
For example,
 spring:
  microtx:
    coordinator-url: http://tmm-app:9000/api/v1
    participant-url: https://bookTicket-app:8081
    propagation-active: true
    http-client-connection-pool-size: 60
    xa-transaction-timeout: 60000
    xa-xa-support: true
    xa-llr-support: false
    xa-lrc-support: false
    xa-llr-delete-commit-record-interval: 720000
    xa-resource-manager-id: 174A5FF2-D8B1-47B0-AF09-DA5AFECA2F61
    xa-promotable-active: false
    xa-rac-active: false

You can use the HTTP protocol if your application and MicroTx are in the same Kubernetes cluster, otherwise use the HTTPS protocol.

You can also provide these configuration values as environment variables. Note that if you specify values in both the application.yaml file as well as the environment variables, then the values set in the environment variables override the values in the properties file.

The following example provides sample values to configure the environment variables.

export SPRING_MICROTX_COORDINATOR_URL = http://tmm-app:9000/api/v1
export SPRING_MICROTX_PARTICIPANT_URL = http://bookTicket-app:8081
export SPRING_MICROTX_PROPAGATION_ACTIVE = true
export SPRING_MICROTX_HTTP_CLIENT_CONNECTION_POOL_SIZE = 15
export SPRING_MICROTX_XA_TRANSACTION_TIMEOUT = 60000
export SPRING_MICROTX_XA_XA_SUPPORT = true
export SPRING_MICROTX_XA_LLR_SUPPORT = false
export SPRING_MICROTX_XA_LLR_DELETE_COMMIT_RECORD_INTERVAL = 720000
export SPRING_MICROTX_XA_LRC_SUPPORT = false
export SPRING_MICROTX_XA_RESOURCE_MANAGER_ID = 174A5FF2-D8B1-47B0-AF09-DA5AFECA2F61
export SPRING_MICROTX_PROMOTABLE_ACTIVE = false
export SPRING_MICROTX_XA_RAC_ACTIVE = false

Note that the environment variables names are case-sensitive.