4.3.4 Develop Micronaut Apps with Saga

You can integrate the MicroTx Distributed Transactions library files with Micronaut applications that use the Saga transaction protocol.

For reference information about the MicroTx Distributed Transactions library for Micronaut applications, see Oracle® Transaction Manager for Microservices Micronaut API Reference for Saga.

To integrate the MicroTx Distributed Transactions library files with your Micronaut applications:

  1. Include the MicroTx Distributed Transactions Java library file as a maven dependency in the Micronaut application's pom.xml file. The following sample code is for the 26.1 release. Provide the correct version, based on the release version that you want to use.
    <dependency>
         <groupId>com.oracle.microtx.lra</groupId>
         <artifactId>microtx-lra-micronaut</artifactId>
         <version>26.1</version>
    </dependency>
  2. Specify values for the MicroTx Distributed Transactions library properties in the application.properties file of your application. This enables the custom library to establish communication with the MicroTx Distributed Transactions Saga coordinator, participate in Saga transactions, and propagate the relevant headers for the coordinated transactions. See Configure MicroTx Distributed Transactions Library Properties for Java Apps.
  3. Import the com.oracle.microtx.lra.annotation.* package.
    import com.oracle.microtx.lra.annotation.*
Source code of a sample Micronaut transaction initiator application which uses the MicroTx Distributed Transactions library is available in the trip-manager-micronaut folder in the microtx-samples GitHub repository. Source code of a sample Micronaut transaction participant application which uses the MicroTx Distributed Transactions library is available in the flight-micronaut folder in the microtx-samples GitHub repository. You can use these files as a reference while integrating the MicroTx libraries with your application.