Azure 服务总线和强类型消息。可以在微服务之间共享代码吗?

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

我正在开发一些微服务。他们将通过 Azure 服务总线进行通信。我希望消息作为强类型对象发送和接收。

我创建一堆 类 来表示消息是否违反了微服务原则?

我可能会将这些 类 放在我在每个微服务中使用的 nuget 包中。在这方面,您有任何示例或最佳做法可以指出吗?

我不会称其为 'violation',而是一种设计选择。例如,当使用诸如 NServiceBus 或 MassTransit 之类的磨损抽象时,您的设计是在服务之间使用 strongly typed messages. Those are contracts and are expected to be shared