MassTransit-配置多个主题的RecectEndPoint
我正在研究以下实施:
有一个应用程序来管理一些实体,例如公司,客户等。 该数据需要由另一个应用程序消费才能做一些事情。 基本思想是通过 massTransit 使用消息传播(RabbitMq-aws)实现 Pub/sub 模型。 将消耗这些消息的应用程序是ASPNETCORE 6,我正在尝试弄清楚如何正确配置 receedEndpoints ,因为我是新的消息传递...
这是我到目前为止得到的。 ..
services.AddMassTransit(busCfg =>
{
busCfg.AddConsumers(typeof(TheAssemblyThatContainsTheMessageSignatures).Assembly);
busCfg.UsingRabbitMq((context, cfg) =>
{
// OPTION 1:
// ONE ReceiveEndpoint (queue) for all messages.
cfg.ReceiveEndpoint("MyCompany.MyServiceName", e =>
{
e.ConfigureConsumer<CompanyCreatedConsumer>(context);
e.ConfigureConsumer<CompanyUpdatedConsumer>(context);
e.ConfigureConsumer<ClientCreatedConsumer>(context);
e.ConfigureConsumer<ClientUpdatedConsumer>(context);
e.ConfigureConsumer<OtherEntityCreatedOrUpdatedConsumer>(context);
});
// OPTION 2:
// A ReceiveEndpoint per entity-type.
cfg.ReceiveEndpoint("MyCompany.MyServiceName.Company", e =>
{
e.ConfigureConsumer<CompanyCreatedConsumer>(context);
e.ConfigureConsumer<CompanyUpdatedConsumer>(context);
});
cfg.ReceiveEndpoint("MyCompany.MyServiceName.Client", e =>
{
e.ConfigureConsumer<ClientCreatedConsumer>(context);
e.ConfigureConsumer<ClientUpdatedConsumer>(context);
});
cfg.ReceiveEndpoint("MyCompany.MyServiceName.OtherEntityCreatedOrUpdated", e =>
{
e.ConfigureConsumer<OtherEntityCreatedOrUpdatedConsumer>(context);
});
// OPTION 3????
});
});
I'm working on the following implementation:
There is an application for managing a few entities, such as Company, Client, etc.
This data needs to be consumed by another application in order to do some stuff.
The basic idea is to implement a Pub/Sub model using a message-broker (RabbitMq-AWS) through MassTransit.
The application that will consume those messages is an AspNetCore 6 and I'm trying to figure out how to properly configure ReceiveEndpoints as I'm kinnda new to messaging...
This is what I got so far...
services.AddMassTransit(busCfg =>
{
busCfg.AddConsumers(typeof(TheAssemblyThatContainsTheMessageSignatures).Assembly);
busCfg.UsingRabbitMq((context, cfg) =>
{
// OPTION 1:
// ONE ReceiveEndpoint (queue) for all messages.
cfg.ReceiveEndpoint("MyCompany.MyServiceName", e =>
{
e.ConfigureConsumer<CompanyCreatedConsumer>(context);
e.ConfigureConsumer<CompanyUpdatedConsumer>(context);
e.ConfigureConsumer<ClientCreatedConsumer>(context);
e.ConfigureConsumer<ClientUpdatedConsumer>(context);
e.ConfigureConsumer<OtherEntityCreatedOrUpdatedConsumer>(context);
});
// OPTION 2:
// A ReceiveEndpoint per entity-type.
cfg.ReceiveEndpoint("MyCompany.MyServiceName.Company", e =>
{
e.ConfigureConsumer<CompanyCreatedConsumer>(context);
e.ConfigureConsumer<CompanyUpdatedConsumer>(context);
});
cfg.ReceiveEndpoint("MyCompany.MyServiceName.Client", e =>
{
e.ConfigureConsumer<ClientCreatedConsumer>(context);
e.ConfigureConsumer<ClientUpdatedConsumer>(context);
});
cfg.ReceiveEndpoint("MyCompany.MyServiceName.OtherEntityCreatedOrUpdated", e =>
{
e.ConfigureConsumer<OtherEntityCreatedOrUpdatedConsumer>(context);
});
// OPTION 3????
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请按照 documentation ,并且只使用
configure> configureendpoints
。您试图过度思考解决方案只会分散您的注意力。MassTransit已经知道如何根据消费者名称配置接收端点,因此只需使用它即可。
Follow the documentation, and just use
ConfigureEndpoints
. Your attempt to over think a solution will just distract you.MassTransit already knows how to configure receive endpoints based upon the consumer names, so just go with it.