Reputation: 10140
I have a case to publish message from remote host to rabbitmq using rabbitmq/api and i'd like to pass handling of published message to MassTransit consumer.
As i could notice, "minimal needed properties" of success handled message with MassTransit consumer looks like this:
Payload:
{
'messageId':'86fd0000-17e1-ac9e-4bde-08d3f1e8553e',
'correlationId':'86fd0000-17e1-ac9e-4165-08d3f1e8553e',
'conversationId':'86fd0000-17e1-ac9e-4d99-08d3f1e8553e',
'messageType':[
'urn:message:Tm.Core.Integration.RabbitMq.Bus.Extension:EndScenario',
'urn:message:Tm.Core.Integration.RabbitMq.Command:IEndScenario',
'urn:message:Tm.Core.Integration.RabbitMq.Command:ICommand'
],
'message':{
'correlationId':'86fd0000-17e1-ac9e-4165-08d3f1e8553e',
'scenarioId':'6c3fda36-8ded-41f0-9536-dd76cd146963'
}
}
As you can see, messageType property contains information, that helps to pass it into responsible consumer (isn't it?).
I'd like to ask you, is there a way i could remove that property and continue to handle passed like this way messages using MassTransit consumer? I'm really afraid that sooner or later some of refactoring will break my code (messageType depends on runtime type of message, isn't it?) and i'd like to prevent it.
I understand that i have to write some code of routing (mb get this message and publish another with more information) ?
My goal is to pass message like this:
{
'messageId':'86fd0000-17e1-ac9e-4bde-08d3f1e8553e',
'correlationId':'86fd0000-17e1-ac9e-4165-08d3f1e8553e',
'conversationId':'86fd0000-17e1-ac9e-4d99-08d3f1e8553e',
'message':{
'correlationId':'86fd0000-17e1-ac9e-4165-08d3f1e8553e',
'scenarioId':'6c3fda36-8ded-41f0-9536-dd76cd146963'
}
}
Upvotes: 0
Views: 2209
Reputation: 33268
The messageType
section of the message envelope is required. If not present, the message cannot be deserialized into a class.
The only way you can subscribe to a message with no types is to use a consumer that looks at the JToken
itself, such as:
public JsonConsumer :
IConsumer<JToken>
{}
Upvotes: 1