6.13.2.2 Configure Node.js Apps with a Non-XA Resource

Use the information provided in this section to configure your Node.js transaction participant applications when you use a non-XA resource, such as MongoDB.

  1. Add the MicroTx library for Node.js as a dependency in the package.json file.
    "dependencies": {
        "@oracle/microtx": "<version>"
      }

    Where, <version> is the latest version of the MicroTx library for Node.js.

  2. Configure the property values for the MicroTx library. See Configure Library Properties. To enable logging for Node.js applications, you must set additional properties. See Enable Logs for MicroTx Node.js Library.
    Ensure that you set the value of oracle.tmm.xa.XaSupport as false and the value of oracle.tmm.xa.LLRSupport as true.
    oracle.tmm.xa.XaSupport = false
    oracle.tmm.xa.LLRSupport = true
  3. Configure the MicroTx library properties for the microservice by passing the tmm.properties file in which you have defined the values.
    TrmConfig.init('./tmm.properties');
  4. Import the MicroTx libraries.
    import {Request, Response, Router} from 'express';
    import {XATransactionMethod, XAConfig, TrmConfig, NonXAResource, TrmNonXAResource} from "../trmlib/xa";
  5. Create a router object.
    For example, the following code creates a router object named bankSvcRouter. Provide a unique name for the router.
    const bankSvcRouter = Router();
  6. Implement the NonXAResource interface.

    For example, in the following code sample the MongoDbNonXAResource class implements the NonXAResource interface.

    public class MongoDbNonXAResource implements NonXAResource {
    // Provide application-specific code for all the methods in the NonXAResource interface.
    }
  7. Register the class, which implements the NonXAResource interface, with the MicroTx library for processing the XA operations.

    The following example describes how you can register the MongoDbNonXAResource class, which implements the NonXAResource interface, with the MicroTx library.

    const nonxaResource: NonXAResource = new MongoNonXAResource();
  8. Use the TrmNonXAResource.init() function to specify the NonXAResource object that the MicroTx library uses.
    TrmNonXAResource.init(nonxaResource)
  9. Save the changes.