Skip to content

Latest commit

 

History

History
62 lines (56 loc) · 3.21 KB

README.md

File metadata and controls

62 lines (56 loc) · 3.21 KB

Distributed Transactions with Camel


 ┌────────────────────┐           ┌─────────────────────┐
 │                    │           │                     │                     ┌─────────────┐
 │  Postgres database │◄──────────┤ ◄─────┐             │ ◄──── Get message ─ │             │
 │                    │           │       │             │                     │     AMQ     │
 └────────────────────┘           │    Transaction 1    │                     │             │
                                  │       │             │                     └─────────────┘
 ┌────────────────────┐           │       │             │                            ▲
 │                    │◄──────────┤ ◄─────┘             │────────Commit/Rollback─────┘                            
 │  Mysql database    │           │                     │                            
 │                    │           │                     ├
 └────────────────────┘           │                     │
                                  │    Transaction 2    │
                                  │          │          │
                                  │          │          │
                                  └──────────┼──────────┘
                                             │
                                             │
                                             │
                                             │
                                   ┌─────────▼──────────┐
                                   │                    │
                                   │  BAM Database      │
                                   │                    │
                                   └────────────────────┘
 

How to

Start Postgres, Mysql, AMQ

docker-compose --project-directory=infra up 

Create queue

docker-compose --project-directory=infra run activemq bash

/opt/amq/bin/artemis queue create --name=demo --address=demo --anycast --durable --preserve-on-no-consumers --auto-create-address --url tcp://activemq:61616

Run Integration

mvn spring-boot:run

Demo

  1. Open pgadmin
  2. Open mysql adminer
  3. Open AMQ console

Commit case

  1. Publish message '1' to demo queue
  2. Check demo table in postgres (1 row added)
  3. Check demo table in mysql (1 row added)
  4. Check bam table in postgres (2 rows added)

Rollback case

  1. Truncate demo table in postgres
  2. Publish message '1' to demo queue
  3. Check demo table in postgres (0 rows added)
  4. Check demo table in mysql (0 rows added)
  5. Check bam table in postgres (2 rows added)