Search code examples
azurearchitecturemicroservicesazureservicebus

Azure service bus and strongly typed messages. Is it ok to share code between microservices?


I am developing a number of microservices. They will communicate through azure service bus. I would like the messages to be sent and received as strongly typed objects.

Am I violating the microservice principles by creating a bunch of classes to represent the messages?

I would probably put these classes in a nuget package, that I use in each of the microservices. Any examples or best practice you can point me to on this?


Solution

  • I wouldn't call this 'violation' but rather a design choice. For example, when using wear abstraction such as NServiceBus or MassTransit, you're by design using strongly typed messages. Those are contracts and are expected to be shared between services.