Change in content_type management between 6.2.1 and 6.2.5

188 views
Skip to first unread message

Pierre Seillé

unread,
Jun 29, 2020, 6:35:08 AM6/29/20
to masstransit-discuss
Hello,

We are using RabbitMq and MassTransit in a micro service architecture with dotnet microservices + some java microservices and some message published using Ansible or shell script. 

Using MassTransit 6.2.1 we had no problem consuming MT message having a content_type "application/json". We wanted to update to MT 6.2.5 for Prometheus integration but with this version we have errors "No deserializer was registered for the message content type: application/json." 

We ended up writing a "dummy" deserializer 

    public class BackwardCompatibleJsonDeserializer : JsonMessageDeserializer, IMessageDeserializer
    {
        public const string ContentTypeHeaderValue = "application/json";
        public static readonly ContentType JsonContentType = new ContentType(ContentTypeHeaderValue);

        public BackwardCompatibleJsonDeserializer(JsonSerializer deserializer)
            : base(deserializer)
        {
        }

        ContentType IMessageDeserializer.ContentType
        {
            get { return JsonContentType; }
        }
    }

and plugin it with 

rabbitMqBusConfigurator.AddMessageDeserializer(new System.Net.Mime.ContentType("application/json"), () => new BackwardCompatibleJsonDeserializer(JsonMessageSerializer.Deserializer));


Did something changed in the serializer management between version 6.2.1 and 6.2.5 ?

Chris Patterson

unread,
Jun 29, 2020, 8:14:18 AM6/29/20
to masstrans...@googlegroups.com
Prior to that version, the context_type RabbitMQ header was completely ignored. It is now used first, with the Content-Type header used if content_type is not present.

protected override ContentType GetContentType()
{
return !string.IsNullOrWhiteSpace(Properties.ContentType) ? new ContentType(Properties.ContentType) : base.GetContentType();


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/6bc483d3-e103-46db-8ae5-0f486ef791bbo%40googlegroups.com.

Pierre Seillé

unread,
Jun 30, 2020, 12:12:25 PM6/30/20
to masstransit-discuss
Thanks for the information (and for your work) !

Another problem we had during our updates is the fact the IRequestClient<TRequest, Response>() is now deprecated, and with it the 

        public static IRequestClient<TRequest, TResponse> CreateRequestClient<TRequest, TResponse>(this IBus bus, TimeSpan timeout, TimeSpan? timeToLive = null, Action<SendContext<TRequest>> callback = null)
            where TRequest : class
            where TResponse : class;

In the new version i haven't found a way to set the routing key (i used the callback parameter before to set it along with some headers) which is a huge loss for us. We are in a multi-tenant rabbitmq and a lot of things are based on the fact that the tenant name is the routing key. Will this callback parameter in the CreateRequestClient method or in the GetReponse method be re-introduced in the future release ?

Thanks again

Pierre
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Chris Patterson

unread,
Jul 1, 2020, 10:18:58 AM7/1/20
to masstrans...@googlegroups.com
using(var handle = client.Create(request))
{
    handle.TrySetRoutingKey(...)

    await handle.GetResponse<TResponse>();
}

I think that's right, shooting from memory.

To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/78f79443-e280-4c24-b3c7-fe53224e7705o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages