8.5 Develop JAX-RS Apps with TCC

The MicroTx library intercepts the incoming HTTP calls using JAX-RS filters, and then initiates a new TCC transaction or joins an existing transaction.

Use the following annotation to add TCC functionality to your application code and enlist the participant services.

  • @TCC(timeLimit = 120, timeUnit = ChronoUnit.SECONDS)

    Use this to annotate the application-specific REST resource that you want MicroTx to call to initiate a new TCC transaction or join an existing transaction.

When you add an annotation to a class, the JAX-RS filters look for the annotation to identify the class that participates in the TCC transaction. If the request header does not contain a value for link, then the MicroTx library creates a value for link in the request header and a unique transaction ID. You can use the unique transaction ID to identify, trace, or debug the transaction.

If the request header contains value for link, then the application participates in the existing TCC transaction. All the applications that participate in the transaction share a unique TCC transaction ID. Here's an example value for link in the request header:

link=[<http://tmm-app:9000/api/v1/tcc-transaction/7ff...>; rel="https://otmm.oracle.com/tcc-transaction/internal",<http://tmm-app:9000/api/v1/tcc-transaction/7ff...>; rel="https://otmm.oracle.com/tcc-transaction/external"]

Where, 7ff... is the unique transaction ID. Example values have been truncated with ... to improve readability. When you view the header in your environment, you'll see the entire value.

For information about the MicroTx library, see Oracle® Transaction Manager for Microservices Java (Jakarta) API Reference.

Topics