rebus-org / Rebus.RabbitMq

:bus: RabbitMQ transport for Rebus
https://mookid.dk/category/rebus
Other
65 stars 45 forks source link

content_type of RabbitMQ message #60

Closed marrrschine closed 4 years ago

marrrschine commented 5 years ago

Hi! First at all, awesome project!

I'm using Rebus and Rebus.RabbitMq (5.1.3) with .NET Core 2.2. One question concerning the content_type of a rmq message, which is application/json;charset=utf-8 by default. Can I change this to just application/json? Thanks!

mookid8000 commented 5 years ago

Can I change this to just application/json?

The value is set by the serializer, so if you replace the serializer you can set it to whatever you want.

Only thing to consider, is whether the serializer is able to reliably DEserialize messages from byte[] to a message object without the encoding info.... but I guess you just want to default to UTF-8?

marrrschine commented 5 years ago

For my scenario I can default to UTF-8, yes.

In my opinion, the content_encoding property of a message is in charge of that. I am a little irritated why both, the content_type and the content_encoding property are stringed together in the content_type:

image

Is that what you ment I could achieve by replacing the serializer?

mookid8000 commented 5 years ago

Ah! In this case, what you're dissatisfied with, is how Rebus' RabbitMQ transport maps the rbs2-content-type header to RabbitMQ's built-in header fields, because it simply puts the same value there.

It never occurred to me that RabbitMQ has separate headers for type and encoding, but since this is the case I believe it would make sense to change how Rebus sets those headers.

Since Rebus does not use RabbitMQ's header properties when receiving incoming messages (it uses its own header), it would be a straightforward change to these few lines.

mookid8000 commented 4 years ago

fixed in Rebus.RabbitMq 5.2.0, which is on Nuget.org now 🙂