4 Quick Start with Docker
You can install Docker on your local machine, and then use the runme.sh
script file to install Transaction Manager for Microservices (MicroTx) and run sample applications.
After MicroTx is installed, the transaction coordinator runs in Docker and the sample apps run in your local machine as operating system processes.
Caution:
The instructions provided in this section are specific to test or development environments. Do not use these instructions to set up and use MicroTx in production environments.The runme.sh
script runs the microservices in a non-secure mode.
Note:
As you run therunme.sh
script only in test or development environments, you do not need to provide any authentication details.
The runme.sh
script installs MicroTx, builds the Docker images, and then installs the sample application. You can also run the sample applications without automating these steps using the runme.sh
script file. See Deploy Sample Applications in Transaction Manager for Microservices Developer Guide.
- Set Up the Required Software
Before you begin, ensure that the following software is available on your local machine where you want to run Docker. - Run XA Sample Applications
Run the XA sample application to transfer an amount from one department to another and to understand how you can use MicroTx to coordinate XA transactions. The MicroTx library files are already integrated with the sample application code. - Run Saga Sample Applications
Run the Saga sample application to book a trip and understand how you can use MicroTx to coordinate the transactions. The MicroTx library files are already integrated with the sample application code. - Run TCC Sample Applications
Run the TCC sample application to book a trip and understand how you can use MicroTx to coordinate the transactions. The MicroTx library files are already integrated with the sample application code.
4.1 Set Up the Required Software
Before you begin, ensure that the following software is available on your local machine where you want to run Docker.
- Docker version 20.10.x. See https://docs.docker.com/engine/install/.
- npm version 7.x or later. See https://nodejs.org/en/download/.
- Maven version 3.6 or later. See https://maven.apache.org/download.cgi.
- Java JDK version 11 or later. See https://www.oracle.com/java/technologies/downloads/.
- cURL. See https://curl.se/download.html.
- jq. See https://stedolan.github.io/jq/download/.
Additionally, ensure that ports 8080 to 8083 are free as MicroTx and sample applications use these ports for communication.
Parent topic: Quick Start with Docker
4.2 Run XA Sample Applications
Run the XA sample application to transfer an amount from one department to another and to understand how you can use MicroTx to coordinate XA transactions. The MicroTx library files are already integrated with the sample application code.
The sample application demonstrates how you can develop microservices that participate in XA transactions while using MicroTx to coordinate the transactions. When you run the Teller application, it withdraws money from one department and deposits it to another department by creating an XA transaction. Within the XA transaction, all actions such as withdraw and deposit either succeed, or they all are rolled back in case of a failure of any one or more actions. For details about the sample XA application, see About the Sample XA Application in Transaction Manager for Microservices Developer Guide.
Ensure that you have completed the prerequisites, such as setting up the resource manager. See Prerequisites.
To run the sample XA application using the runme.sh
script file:
- Use the Kiali dashboard to view how the MicroTx handles the flow of requests between the sample microservices.
- Perform distributed tracing using Jaeger to trace the entire transaction. See Perform Distributed Tracing with Jaeger.
- Run another sample application.
- View the source files of the sample application.
- View the log files to find more details about the transactions.
- Create and run your own application using MicroTx.
Parent topic: Quick Start with Docker
4.3 Run Saga Sample Applications
Run the Saga sample application to book a trip and understand how you can use MicroTx to coordinate the transactions. The MicroTx library files are already integrated with the sample application code.
The sample application demonstrates how you can develop microservices that participate in Saga transactions while using MicroTx to coordinate the transactions. When you run the application, it makes a provisional booking by reserving a hotel room and flight ticket. Only when you provide approval to confirm the booking, the booking of the hotel room and flight ticket is confirmed. If you cancel the provisional booking, the hotel room and flight ticket that was blocked is released and the booking is canceled. By default, the hotel and flight service permits only three confirmed bookings. To enable you to test the failure scenario, the services reject any additional booking requests that are made after three confirmed bookings. This leads to the cancellation (compensation) of a provisionally booked hotel or flight within the trip and the trip is not booked. For details about the sample Saga application, see About the Sample Saga Application in Transaction Manager for Microservices Developer Guide.
To run the sample Saga application using the runme.sh
script file:
Parent topic: Quick Start with Docker
4.4 Run TCC Sample Applications
Run the TCC sample application to book a trip and understand how you can use MicroTx to coordinate the transactions. The MicroTx library files are already integrated with the sample application code.
The sample TCC application implements a scenario where the travel agent microservice books a trip, flight booking service books a flight, and the hotel booking microservice books a hotel. The travel agent service accesses both the flight and hotel booking services. When a customer books a flight and a hotel, the booking is reserved until either the customer completes the payment and confirms the booking. In case of any failure, the reserved resources are canceled and the resources are returned back to the inventory. For details about the sample TCC application, see About the Sample TCC Application in Transaction Manager for Microservices Developer Guide.
To run the sample TCC application using the runme.sh
script file:
- Use the Kiali dashboard to view how the MicroTx handles the flow of requests between the sample microservices.
- Perform distributed tracing using Jaeger to trace the entire transaction. See Perform Distributed Tracing with Jaeger.
- Run another sample application.
- View the source files of the sample application.
- View the log files to find more details about the transactions.
- Create and run your own application using MicroTx.
Parent topic: Quick Start with Docker