kira
kira

Reputation: 513

Is there a way to send raw message from MassTransit?

i send some message to rabbitmq exchange "x" by Masstransit like this:

var endpoint = await _bus.GetSendEndpoint(new Uri("exchange:x"));
var message = new CustomType {
  accountId = 1
};
await endpoint.Send(message);

And the event i get in the queue is like below:

{
  "messageId": "x",
  "conversationId": "x",
  "sourceAddress": "rabbitmq://localhost/x",
  "destinationAddress": "rabbitmq://localhost/x",
  "messageType": [
    "urn:message:x"
  ],
  "message": {
    "accountId": 1
  },
  "sentTime": "x",
  "headers": {
    "MT-Activity-Id": "x"
  },
  "host": {
    ...
  }
}

But I want the message in the queue to be like:

{
    "accountId": 1   
}

Is there any way in Masstransit to send raw message to queue?

Upvotes: 1

Views: 2286

Answers (1)

Chris Patterson
Chris Patterson

Reputation: 33258

You can specify the raw JSON message serializer, using:

cfg.UseRawJsonSerializer();

This will send the message as serialized by JSON.NET.

Upvotes: 5

Related Questions