First of all, excuse my English, it's very bad. I am using MassTransit with Azure Service Bus for asynchronous communication between microservices.
Due to project design requirements, the objects sent and / or published in masstransit are objects (class instances) that implement interfaces and have inheritance, which implies that the "MessageType" property is an array of multiple values, which results in a sending/publication of "a copy" of the object for each of the base classes and interfaces of the object.
Since the application really only needs to process the final class, the result of this behavior is that queues and topics of message types are created that are never processed.
Is there a way to modify the MessageType array to remove all unnecessary items?
Example:
This is a current message:
{
"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"
}
}
And this is my goal message (with only one item in messageType property):
{
"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"
}
}
Thank you very much.
Regards
Borja