Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between BrokeredMessage class in Microsoft.ServiceBus and Message class in Microsoft.Azure.ServiceBus

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.

  • BrokeredMessage class: https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.brokeredmessage?view=azure-dotnet
  • Message class: https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.servicebus.message?view=azure-dotnet

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://learn.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.

like image 652
EagleDev Avatar asked Mar 01 '18 08:03

EagleDev


People also ask

What is Microsoft Service Bus messaging?

A client class used in send operations for an Event Hub. Represents a logical sender connection to a specific Event Hub partition.

What is BrokeredMessage?

BrokeredMessage() Initializes a new instance of the BrokeredMessage class. BrokeredMessage(Object) Initializes a new instance of the BrokeredMessage class from a given object by using DataContractSerializer with a binary XmlDictionaryWriter.

What is Service Bus in Azure?

Azure Service Bus is a fully managed enterprise message broker with message queues and publish-subscribe topics (in a namespace). Service Bus is used to decouple applications and services from each other, providing the following benefits: Load-balancing work across competing workers.

Is Microsoft Azure Service Bus deprecated?

This package has been deprecated. Please note, a newer package is available at https://nuget.org/packages/Azure.Messaging.ServiceBus as of 11/2020. While this package will continue to receive critical bug fixes, we strongly encourage you to upgrade.


2 Answers

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.
like image 109
Sean Feldman Avatar answered Oct 23 '22 19:10

Sean Feldman


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.

like image 44
Tom Sun - MSFT Avatar answered Oct 23 '22 18:10

Tom Sun - MSFT