5
votes

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() 
1
There's no built in support that I'm aware of. Why would you want to do this?eulerfx
Why would you want to do this? What about if you receive messages in Json from somewhere but your downstream subscribers want xml? But you can't give them xml because your "message" was received in json? That is a bit rubbish.tom redfern

1 Answers

4
votes

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.