Back to Watermill

Example Golang CQRS application

_examples/basic/5-cqrs-protobuf/README.md

1.5.11.2 KB
Original Source

Example Golang CQRS application

This application is using Watermill CQRS component.

Detailed documentation for CQRS can be found in Watermill's docs: http://watermill.io/docs/cqrs#usage.

mermaid
sequenceDiagram
    participant M as Main
    participant CB as CommandBus
    participant BRH as BookRoomHandler
    participant EB as EventBus
    participant OBRB as OrderBeerOnRoomBooked
    participant OBH as OrderBeerHandler
    participant BFR as BookingsFinancialReport

    Note over M,BFR: Commands use AMQP queue, Events use AMQP pub/sub
    
    M->>CB: Send(BookRoom)
topic: commands.BookRoom
    CB->>BRH: Handle(BookRoom)
    
    BRH->>EB: Publish(RoomBooked)
topic: events.RoomBooked
    
    par Process RoomBooked Event
        EB->>OBRB: Handle(RoomBooked)
        OBRB->>CB: Send(OrderBeer)
topic: commands.OrderBeer
        CB->>OBH: Handle(OrderBeer)
        OBH->>EB: Publish(BeerOrdered)
topic: events.BeerOrdered
        
        EB->>BFR: Handle(RoomBooked)
        Note over BFR: Updates financial report
    end

Running

bash
docker-compose up