Skip to content

schambeck/outbox-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

outbox-pattern

build

Pattern: Transactional outbox

The Transactional outbox pattern implementation using an outbox table.

A separate Message Relay process publishes the events inserted into database to a message broker using the Polling publisher pattern.

Tech Stack

  • Java 17
  • Spring Boot
  • PostgreSQL, Flyway
  • RabbitMQ
  • JUnit 5, Mockito, JaCoCo

Running project

Start infra (PostgreSQL and RabbitMQ)

$ make compose-up

Build artifact

$ make dist

Run backend

$ make run

RabbitMQ Web Interface

$ http://localhost:15672
$ User: guest
$ Pass: guest

API

Creating an order

POST /orders (creates a new order)
Payload
{
  "clientId": "796f5390-6a32-4f3f-a4f9-219cea1d5336",
  "issuedDate": "2023-02-03",
  "items": [
    {
      "productId": "7fba7340-d24f-4548-a327-add2cd2ad4a9",
      "price": 3,
      "quantity": 2
    }
  ]
}
Response

Code : 201 CREATED

{
  "id": "7c08629a-4d23-4b6d-9363-b0f0d7303aa4",
  "clientId": "796f5390-6a32-4f3f-a4f9-219cea1d5336",
  "issuedDate": "2023-02-03",
  "status": "CREATED",
  "totalCost": 6,
  "items": [
    {
      "id": "dcb9f5fe-7423-4542-857e-47ae71322cf3",
      "productId": "7fba7340-d24f-4548-a327-add2cd2ad4a9",
      "price": 3,
      "quantity": 2,
      "cost": 6
    }
  ]
}

Closing an order

POST /orders/{ORDER_ID}/close (closes an existing order)
Payload

None

Response

Code : 200 OK


References