It is a pattern to manage distribuited transactions through microservices, usinf compensation transactions when something works wrong
Command-Query Responsability Segregation. The idea is simple:
But this allow us to improve separating in two parts, Command and Query:
To sync two services, we are using an Event Sourcing
pattern.
Types of messages:
- Commnand: Express the intent to change the application's state. Ex. CreateProductCommand. Use imperative way to describe.
- Query: Express the desire for information. Ex. FindProductQuery. Use words like
find
orget
to describe. - Event: Notification that something relevant has happend. Ex. ProductCreatedEvent. This kind of message comes from
Event Sourcing
.
- Eventuate: has two options,
Eventuate Tram
, that use traditional persistence (JPA) andEventuate Local
, that use event sourcing. - Axon: Open source to event-driven microservice and CQRS.
Run as docker container:
docker run --name local-axon-server -p 8024:8024 -p 8124:8124 -v <localfolder>/axon/data:/data -v <localfolder>/axon/eventdata:/eventdata -v <localfolder>/axon/config:/config axoniq/axonserver
note: 8024 for HTTP and 8124 for gRPC
Some properties can be configured in a config file:
server.port
allows us to change the port of axon serveraxoniq.axonserver.devmode.enabled
if set true, allows us to remove all event stored on the server