Advice for managing message definitions across microservices

Hey, I’m wondering if there is a recommended approach to managing message definitions. If I have multiple services that are listening for the same Events, is there a “best practice” for maintaining each definition? Two obvious approaches are the following: 1.) Every service defines its own version of the Events for which it’s listening. 2.) All services share a common library of defined Events that are used across the domain.

Any thoughts on this would be greatly appreciated!

Hi, first of all with any “common libraries” you will hit another problems in the microservice world. E.g. once the librariy is updated all the services depending on ti become outdated and have to be updated an deplyoed and so on. So “common library” is usually an antipattern for microservices.

Regarding Event Driven Microservices
I’m also new to the topic, but usually i asume the common approch would assume, that there should be one to one relation between Service and a typed stream of event it produces. So theoretically you could have a library that is ussed by clients of this stream that has versions of desired object. It would not be the common lib for all possible events in the system, but a subset u’ll found usefull over time.

But you don’t know in advance. A the beginnign you will have only one or few consumers anyway. Why not just starting with implementation in the services not spend time on “common lib” and see how it works. You still have the option to externalize the common parts to a library later. Usually this refactoring is not costly at all.

P.S. you used “message definition” in the first sentence but you still mean “event” i guess.

Hey thanks for the insight.

I hadn’t heard that a common library between micro services is seen as an anti pattern. I’ll take a look into that.

When I said Message definition, I meant it to apply to all of the shared definitions for objects that can be routed and handled across microservices via the Axon Server. So events, commands, queries. The question applies to any and all that fit into that category.

In my presentation on the past event-driven microservices event, I talk about this topic of governance.

I think soon they will be putting presentations/videos online.

1 Like

“A road story about using AxonServer in an enterprise context with multiple teams”

Is this the one, Christian?

Yes, that’s the one.
We use:

  • Pact (‘can I deploy?’)
  • OpenAPI (SwaggerHub), although it’s not ideal
  • own maven plugin to generate Axon annotations from meta data (extensions) in swaggerhub
    More info in the presentation.