1
votes

I am new to Axon framework and we are using Axon 3.3.3 with Mongo DB as Event Store.

We would like to know the best option to generate Aggregate Id with Microservices, as we see problem with loading events from event store

Example : we have order service and product service.

orderService generated aggregate id as 101 of type OrderAggregate and it has been stored into the event store.

If product service also generated id as 101 of type ProductAggregate.

Then how can we load particular micro service events from event store

1

1 Answers

2
votes

I generally recommend not using sequential numbers. Besides the fact that it is a process that is hard to scale, you tend to easily bump into duplicates, and the scope of the sequential numbers is generally on the entity-type level.

Instead, consider using UUIDs (using UUID.random()) for your aggregates. They can be generated by the sender of commands, allowing the identifier of an aggregate to be used to consistently route messages, including the creation method, to the same machine. This would allow you to configure caching on the handling side, and be sure that any updates are sent to the same node where the aggregate was created.