简体   繁体   English

如何托管MassTransit和RabbitMq

[英]How to host MassTransit and RabbitMq

We are working towards an architecture like one below but we will have micro services on cloud and some on premises which will talk to each other using queue(s) and bus(es), 我们正在努力建立一个类似下面的体系结构,但我们将在云上提供微服务,一些内部将使用队列和总线相互通信,

RabbitMQ实现了一个事件总线

Now I am confused with where we should host MassTransit and RabbitMq, also should it be a ASP.NET Core project on its own ? 现在我对我们应该托管MassTransit和RabbitMq的地方感到困惑,它本身也应该是一个ASP.NET核心项目吗? if yes what I will be doing in it ? 如果是的话我会做什么呢? starting a bus ? 开公共汽车? creating queues ? 创建队列? I am not able to move forward with this 我无法继续前进

The simple MassTransit examples are just that, the absolute simplest examples of interacting with queues. 简单的MassTransit示例就是与队列交互的绝对最简单的示例。

  1. RabbitMQ is your message broker. RabbitMQ是您的消息代理。 It is hosted separately. 它是单独托管的。
  2. MassTransit is a development framework that makes it much easier to interact with RabbitMQ (or Azure Service Bus) by abstracting away the implementation-specific "plumbing." MassTransit是一个开发框架,通过抽象出特定于实现的“管道”,可以更轻松地与RabbitMQ(或Azure Service Bus)进行交互。
  3. You write any number of .NET services that either publish messages to a queue, or subscribe to queues. 您可以编写任意数量的.NET服务,这些服务可以将消息发布到队列,也可以订阅队列。

We recently worked on something similar, the way we did it is: 我们最近在做类似的事情,我们这样做的方式是:

RabbitMQ was hosted separately, and buses/queues creation and management were done from the services that use messaging. RabbitMQ是单独托管的,并且使用消息传递的服务完成了总线/队列的创建和管理。

For each service that receives messages you use Maastransit to create a queue because service will be receiving messages using this queue. 对于接收消息的每个服务,您使用Maastransit创建队列,因为服务将使用此队列接收消息。

You will be using publish/subscribe way of messaging so as mentioned above, inside each service, create a queue with logical name and connect to RabbitMQ server address. 您将使用发布/订阅消息传递方式,如上所述,在每个服务中,创建一个具有逻辑名称的队列并连接到RabbitMQ服务器地址。

Services that represent senders will publish messages of a custom type you create, and services that represent receivers will subscribe to this type of messages by having a consumer for this type registered inside the bus created. 代表发件人的服务将发布您创建的自定义类型的消息,代表接收者的服务将通过在创建的总线内注册此类型的使用者来订阅此类消息。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM