2

We’re migrating from a monolithic application to microservice and we use event sourcing and CQRS. Each service has its own read models. When a service needs to insert data, it fires an event. The services which use that data, will update their read models. The challenge I'm facing now is how to deal with static data. Back when we had a monolithic application, we had created some database scripts to insert these into the database. Now that every service has its own read model how should we insert this static data?

My database is postgresql.

Sheida
  • 21
  • 3

1 Answers1

0

There are a few possibilities which come to mind.

If the static data is just to enable further normalization in a relational DB, since CQRS/ES tends to denormalize, you may well be able to do without it and just include the denormalized data in your events.

Alternatively, you can provide the static data as its own stream of events (note that this stream will be fairly "dry" with very few events flowing). Read models that need it can incorporate it (perhaps by incorporating it as static data in their DB).

If the data is exceptionally static and all your services are implemented in the same language, it might also make sense to build it into a library.

Levi Ramsey
  • 18,884
  • 1
  • 16
  • 30