Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible for an NServiceBus endpoint to Handle and Publish using different serializers?

I have a single endpoint which handles incoming messages (from a Bus.Send), does some work and then publishes another message. Is it possible to configure it to deserialize incoming messages using the Json serializer, but when publishing, serialize the outgoing message using the Xml serializer?

My config currently looks like below which uses the Json serializer for both deserializing incoming and serializing outgoing messages:

        Configure.With()
            .DefaultBuilder()
            .JsonSerializer()
            .MsmqTransport()
            .IsTransactional(true)
            .PurgeOnStartup(false)
            .UnicastBus() 
like image 560
JamesM Avatar asked Oct 07 '22 05:10

JamesM


1 Answers

UPDATE

Basic support for this scenario was added with version 5 of NServiceBus and has been made quite a bit more complete in version 6.

Here's some more info on the topic:

https://particular.net/blog/build-a-babel-fish-nservicebus

OLD RESPONSE: This is something that we on the NServiceBus team have been thinking about for some time now. It does make sense to use one serialization format within one system and to do pub/sub communication with other systems using a different serialization format.

I'm afraid that we haven't gotten around to implementing it yet so you're currently stuck with choosing just one.

like image 173
Udi Dahan Avatar answered Oct 10 '22 02:10

Udi Dahan