23
votes

I've got started with Azure Service Bus in Azure. Having gone through some references over the Internet, it seems that people use BrokeredMessage class in Microsoft.ServiceBus.Messaging rather than Message class in Microsoft.Azure.ServiceBus.

I can send both of message 'types' to Azure Service Bus and also work with them over Azure Service Bus. Also, both can be used in Asynchronous operation. What are the main differences between the two types?

[Update] This article gives best practices of Azure Service Bus when exchaning brokered message (https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-performance-improvements). I'm unsure if it is also referred to Message in Microsoft.Azure.ServiceBus.

2
I think the difference is in the library (SDK): Microsoft.Azure.ServiceBus is the newer version of the library built using .Net Standard while Microsoft.ServiceBus is the older version of the library built using .Net Framework.Gaurav Mantri
Thank you @GauravMantri. I kind of thought so but I'm unsure about that :). This quite new article (written 1 month ago) used BrokeredMessage docs.microsoft.com/en-us/azure/service-bus-messaging/…EagleDev
The article you referred to is actually last edited one month ago :). You can look at the history here: github.com/MicrosoftDocs/azure-docs/commits/master/articles/….Gaurav Mantri
Yes saw it. But I still have doubts about which should be used. Is Microsoft not encouraging new library?EagleDev
Since the new library only supports Queues & Topics, if you are only using those, then my recommendation would be to use the new one. However if you're using Relays and Event Hubs, old library should be used as they are not supported in the new one. Plus other consideration is the .Net framework are you using.Gaurav Mantri

2 Answers

19
votes

If it's a new project to use Azure Service Bus, I would recommend the following:

  • Prefer the new .NET Standard client (Microsoft.Azure.ServiceBus) with Message.
  • Be careful with documentation and various resources. They mostly cater to the old client (hopefully MSFT doco soon to change).
  • If you need transport transactions spanning different entities, the new client can't provide it yet.
  • If you need management operations, the new client won't provide it. Ever. Instead you'd have to use Management library or wait till a replacement package for NamespaceManager is out.
  • If you have old systems emitting messages sent as serialized data and not Stream, implementations using new Client have to know about it and use extension method provided by the client to process those messages. New client only deals with Stream based messages.
2
votes

As Gaurav Mantiri mentioned that Microsoft.Azure.ServiceBus is the newer version of the library built using .Net Standard.

You could get the detail information from github.

This is the next generation Service Bus .NET client library that focuses on queues & topics. This library is built using .NET Standard 1.3.