Search code examples
c#jsonrabbitmqmasstransit

Masstransit consumer raw message


Someone put a message in RabbitMq (for example). The message is not in the Masstransit "envelop" format, just json, or maybe something else. How to get this message in Masstransit consumer as byte[], or string?

I understand that Masstransit has its own message format, but there is a need to receive a raw message. I don’t really like the option when Masstransit and RabbitMq client are used in one service, because these are already two connections, and different message processing logic.


Solution

  • On the receive endpoint where raw JSON messages are to be consumed, you can configure a default deserializer as shown:

    endpointConfigurator.UseRawJsonDeserializer(isDefault: true);