Is it possible to map the NServiceBus.EnclosedMessageTypes to a specific type for message deserialization?


(Jeremy) #1

I’m assuming that it is the NServiceBus.EnclosedMessageTypes header which is used to choose the message type for deserialization when a message is received by the consumer. Is that correct?

Would it be possible to map that to a specific type? The use case is non-.Net systems. We have a growing microservice architecture and another team is using NodeJS. I know the typical workaround is to just create an API endpoint to receive HTTP requests and then turn them into events, but for commands, it seems there’s at least something that could be done.

I suppose they could frame the messages normally and drop them in RabbitMQ, for example, but FQAN isn’t exactly something that team is going to be able to keep up with. So if they could set that header to something like “DoTheThing” and we could map that to “MyService.Messaging.DoTheThingCommand” so long as NSB could resolve that somehow. Looks like it might be an enhancement to Looks like it might be in MessageDeserializerResolver. Maybe it’s more complicated than that. Just a thought.

(Mauro Servienti) #2


It can be done by manipulating the incoming message. Take a look at the following articles:

Even if they are not exactly what you’re looking for they should give you a good enough overview of what can be done.

Let me know if this works for you, I could also work on a sample specifically designed around your scenario.