CQRS, EventSourcing, where is the metadata?

Viewed 99

If an aggregate is "metadata driven", and such metadata needs to be managed centrally together with metadata of other aggregates, is this anti pattern?

For instance, there are metadata for product, user, action etc so product type, user group or action type don't get hardcoded. There is also a single metadata microservice that manages all metadata (large amount of versioned data).

How should a product microservice get its metadata for things like command validation?

Any suggestions on how to model this in Axon?

1 Answers

I am not overly convinced it makes sense to construct a separate service just for MetaData management. Then again, I am not a domain expert of the entire world, so I might be completely off with that assumption.

I feel that using the term MetaData sounds overloaded if you're also speaking about making it a central service. Maybe there's another term that makes more sense?

At any rate, I think it's valuable to know that Axon Framework supports the notion of MetaData for every type of message. Hence, Commands, Events, and Queries will always carry a MetaData object. This MetaData is, in all honesty, just a Map of String to ?, which can store whatever metadata you have.

In most cases, this includes fields like a userId, traceId, correlationId, some form of security information. Furthermore, in most cases this does not include first-class citizen data like productTypes, as far as I know.

To come back to your original question:

If an aggregate is "metadata driven", and such metadata needs to be managed centrally together with metadata of other aggregates, is this anti pattern?

I can't say for sure that it's an anti-pattern to model a service to manage all metadata. However, it does feel like unnecessary complexity to me. Be sure to update your question with more information to clarify your idea, Bing. I'll be sure to update my response once you've done that.

Related