MassTransit.编辑用于删除不必要项的MessageType属性



首先,对不起,我的英语很差。我正在使用MassTransit和Azure服务总线进行微服务之间的异步通信。

由于项目设计要求,在masstrait中发送和/或发布的对象是实现接口并具有继承性的对象(类实例(,这意味着;消息类型"属性是多个值的数组,这导致发送/发布";副本";对象的每个基类和接口的对象的。

由于应用程序实际上只需要处理最后一个类,因此这种行为的结果是创建了从未处理过的队列和消息类型的主题。

是否有方法修改MessageType数组以删除所有不必要的项?

示例:

这是一条最新消息:

{
"messageId": "c93e0000-eab0-3663-c954-08d89e1f87cb",
"correlationId": "42fc2237-77b1-4994-821d-87790b6caf06",
"conversationId": "c93e0000-eab0-3663-f342-08d89e1f87cd",
"sourceAddress": "sb://bus.servicebus.windows.net/tmspayments7dc9d65778jfh75_dotnet_bus_3r9yyy8ksy5g84tdbdcjasmhg9",
"destinationAddress": "sb://bus.servicebus.windows.net/queue",
"messageType": [
"urn:message:Payments.Application.Integration.Outcoming.Commands.Sales:NotifySalePaymentHasCanceledCommand",
"urn:message:Payments.Application.Integration.Outcoming.Commands:BaseIntegrationOutcomingCommand",
"urn:message:Tms.Frameworks.CqrsEs.Cqrs.Commands:IdentifiedCommandBase",
"urn:message:Tms.Frameworks.CqrsEs.Cqrs.Messages:MessageBase",
"urn:message:Tms.Frameworks.CqrsEs.Cqrs.Messages:IIdentifiedMessage",
"urn:message:Tms.Frameworks.CqrsEs.Cqrs.Messages:IMessage",
"urn:message:Tms.Frameworks.CqrsEs.Cqrs.Commands:IIdentifiedCommand",
"urn:message:Tms.Frameworks.CqrsEs.Cqrs.Messages:ICommand",
"urn:message:Tms.Frameworks.CqrsEs.Cqrs.Commands.Outcoming:IOutcomingCommand",
"urn:message:Tms.Frameworks.CqrsEs.Cqrs.Messages:IOutcomingMessage"
],
"message": {
"commandId": "42fc2237-77b1-4994-821d-87790b6caf06",
"terminalId": 71,
"paymentId": "a28a23e9-3ba5-464f-9a20-d25d1991ab46"
},
"sentTime": "2020-12-11T21:55:53.252599Z",
"headers": {},
"host": {
"machineName": "tms-payments-7dc9d65778-jfh75",
"processName": "dotnet",
"processId": 1,
"assembly": "Payments.Api",
"assemblyVersion": "1.0.0.0",
"frameworkVersion": "3.1.8",
"massTransitVersion": "5.5.2.0",
"operatingSystemVersion": "Unix 4.15.0.1098"
}
}

这是我的目标消息(messageType属性中只有一项(:

{
"messageId": "c93e0000-eab0-3663-c954-08d89e1f87cb",
"correlationId": "42fc2237-77b1-4994-821d-87790b6caf06",
"conversationId": "c93e0000-eab0-3663-f342-08d89e1f87cd",
"sourceAddress": "sb://bus.servicebus.windows.net/tmspayments7dc9d65778jfh75_dotnet_bus_3r9yyy8ksy5g84tdbdcjasmhg9",
"destinationAddress": "sb://bus.servicebus.windows.net/queue",
"messageType": [
"urn:message:Payments.Application.Integration.Outcoming.Commands.Sales:NotifySalePaymentHasCanceledCommand"
],
"message": {
"commandId": "42fc2237-77b1-4994-821d-87790b6caf06",
"terminalId": 71,
"paymentId": "a28a23e9-3ba5-464f-9a20-d25d1991ab46"
},
"sentTime": "2020-12-11T21:55:53.252599Z",
"headers": {},
"host": {
"machineName": "tms-payments-7dc9d65778-jfh75",
"processName": "dotnet",
"processId": 1,
"assembly": "Payments.Api",
"assemblyVersion": "1.0.0.0",
"frameworkVersion": "3.1.8",
"massTransitVersion": "5.5.2.0",
"operatingSystemVersion": "Unix 4.15.0.1098"
}
}

非常感谢。

问候

Borja

简短回答:无

MassTransit将反映所有支持的类型,并将它们包含在消息信封中,以支持多态消息传递和反序列化。

您可以排除在消息代理上创建为交换/主题的消息类型,但这不会在序列化期间将它们从消息类型数组中排除。

最新更新