Eventuate is a framework that makes event-driven microservices easy. It simplifies a lot our work, as it has change data capture(CDC), message broker(Kafka) and a event store (Eventuate). For more information regarding eventuate you can start with this.
Now let’s apply this on our known use case(items and bids). First of all, a picture will offer an high level view of what we have.

The same structure will apply for items.

An a important thing to remember. The event store is the same; this is the way services will communicate with each other.

The use case is pretty straight-forward. An item will be created, triggering an item created event. This event will update the items materialized view. Multiple bids will be made, triggering multiple bid events which will update the bids materialized view. Bids will be evaluated, that means the corresponding item will be updated through an item updated event; and of course the items view will be updated again.
Everything is deployed in docker containers. If you are on OSX like me you need to do this first. After running

you should be able to run docker (the ip is the one I’ve used, you can choose another fi you want).
These will be build using docker compose.

After the containers are up are running just run docker ps to see the processes.
Let’s do some http calls. First of all we create an item.

Check the items.

Next, some bids on the item.



Check the bids.

Evaluate the bids.

Check the bids.

Cool, pretty straightforward.
One drawback of CQRS is that you need to split the microservice in command and query which makes two component to maintain. Some of you will think this is a distributed monolith. But overall it’s a clean solution: commands -> events -> queries.
SOURCE CODE
Like this:
Like Loading...
Nice short post on CQRS. I’d love to read a deeper dive into eventuate – the issue I have is that they don’t appear to support conditional writes, which makes the events subject to race validation. I have a talk on this I’d appreciate your feedback on, where I’ve collated about 4+ years of research on the principles of DDDD/ES to try to build a community conversation around this: https://t.co/1lEwjjCYp9
LikeLike