Home > Software engineering >  A design challenge using MassTransit, .NET Core and RabbitMQ
A design challenge using MassTransit, .NET Core and RabbitMQ

Time:05-11

I have a product with .NET Core and using MassTransit for RabbitMQ message broker.

I have two microservices here as follows:

  1. Product Microservice

  2. Product Feature

When the product is created in my app, ProductCreated event is fired and message is published in RabbitMQ.

My goal is using ProductCreated schema in the product features microservice. In addition I don't want to recreate the ProductCreated class in the Product features microservice.

My solution is putting the domain layer of product microservice on NuGet then adding it to product features microservice. There is one problem with this: if the ProductCreated schema will be changed, I have to repackage the ProductCreated schema and again put it on NuGet, and finally upgrade the package version in the product features microservice.

Is there any way to overcome this challenge? Or is there any better solution?

CodePudding user response:

Creating a shared NuGet package with message contracts is a fairly common solution, and one that many teams use.

As long as message contracts are backwards compatible, consumers of previous contract versions should not have any issues. That takes care and discipline, but isn't something that is difficult.

  • Related