November 28, 2023

Azure Service Bus overview

Azure Service Bus is a fully managed message broker.

Types of messaging scenarios:

  • Messaging – Transfer of data from one component/service to another
  • Decouple applications – Use a message broker to remove dependencies between service A and service B
  • Load balancing – Multiple consumers read from a message queue at the same time allowing concurrent work flows
  • Topics and subscriptions – A publisher sends a message using a specific topic. This is received by one or many subscribers to that topic
  • Transactions – Perform multiple operations under the scope of an atomic transaction

Service Bus concepts and terminology

  • Namespace – Multiple queues and topics can be in a single namespace. Namespaces can span availability zones.
  • Queues – Messages in queues are ordered and timestamped on arrival. Messages are delivered using pull requests. The pull operation can be long-lived and only complete once a message is available.
  • Topics – Use to implement the publisher-subscriber design pattern. You can define rules on a subscription to filter on topics. If the filter matches a given topic then that message will be forwarded to the subscriber.
  • Message sessions – Allows you to guarantee ordered receipts of related messages I.e. FIFO (first-in, first-out).
  • Auto-forwarding – is a feature which chains a queue or subscription to another queue or topic in the same namespace.
  • Dead-letter queue (DLQ) – Messages on the DLQ are annotated to state the reason why they are there. The DLQ can be browsed or dequeued. You can also auto-forward out of a DLQ. A DLQ holds the following types of messages:
    • Can’t be delivered to any receiver
    • They have timed out
    • There are explicitly ignored by the receiver
  • Scheduled delivery – Messages sent to the service bus can be scheduled to be processing at a later time. You can cancel the scheduled messages too.
  • Message deferral – A queue or subscription can defer retrieval of a message until a later time.
  • Batching – This allow messages to be batched together on the client side and then transfer them together.
  • Transactions – A transaction groups two or more operations together into an execution scope. Service Bus allows you to group operations against multiple messaging entities within the scope of a single transaction. A message entity can be a queue, topic, or subscription.
  • Autodelete on idle – you can specify a message to be autodeleted if it has not been processed within a given period. The minimum duration is 5 minutes.
  • Duplicate detection – Service Bus can use the ‘message-id’ property of a message can be used to detect for duplicates.
  • Geo-disaster recovery – When an Azure region experiences downtime, the disaster recovery feature enables data processing to continue operating in a different region or data center.
  • Security – Service Bus supports standard AMQP 1.0 and HTTP or REST protocols and their respective security facilities, including transport-level security (TLS). Clients can be authorized for access using Shared Access Signature or Azure Active Directory role-based security.