'Can you use the new Azure Service Bus Library with the previous one?

The new service bus library Azure.Messaging.ServiceBus uses the ServiceBusReceivedMessage for a received message

https://docs.microsoft.com/en-us/dotnet/api/azure.messaging.servicebus.servicebusreceivedmessage?view=azure-dotnet

The older libraries uses a different message format for service bus triggers being the Microsoft.Azure.ServiceBus.Message

https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.servicebus.message?view=azure-dotnet

If I post an old style Message to the service bus, will I be able to retrieve it using the new library and format.



Solution 1:[1]

Client SDKs operate against the same service. What matters is the agreement between the sending and the receiving parties on the message payload and encoding. As long as both parties agree on that, there's no problem sending messages using older SDK and receiving using newer SDK.

You should be careful when sending messages using the oldest SDK, WindowsAzure.ServiceBus. That SDK used XmlObjectSerializer to serialize the body which is not the same as a byte array that is used by the newer SDK Microsoft.Azure.ServiceBus and the latest SDK Azure.Messaging.ServiceBus. If you do need to interop with the oldest SDK, there's a sample to follow.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sean Feldman