Announccing "azservicebus" - an AMQP 1.0 client for Azure Service Bus

azservicebus 0.1

I am happy to announce the initial release of azservicebus, which is an unofficial AMQP 1.0 protocol based client for Azure Service Bus.


How is it different from the existing azure_messaging_servicebus?

The keyword is "AMQP 1.0". The current azure_messaging_servicebus is simply a wrapper over the Azure Service Bus REST API (Azure Service Bus REST API reference | Microsoft Learn), which itself only offers a subset of Service Bus features (see REST vs dotnet client support). This crate already offers more features than the REST API (see supported Service Bus features). The only features that are not implemented yet (in comparison to the dotnet sdk) are

  1. Transaction
  2. ServiceBusProcessor
  3. ServiceBusSessionProcessor

The overall structure follows that of the dotnet sdk and golang sdk. So if you have used either of those, you should find yourself familiar with this crate. Plus, there are many examples that should help you getting started quickly (see examples).

A short example

A short example of sending to the queue is provided below to just give you a quick look. More example can be found on the github repo examples.

//! This is the same example shown in the crate-level documentation

use azservicebus::prelude::*;

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Replace "<NAMESPACE-CONNECTION-STRING>" with your connection string,
    // which can be found in the Azure portal and should look like
    // "Endpoint=sb://<NAMESPACE>;SharedAccessKeyName=<KEY_NAME>;SharedAccessKey=<KEY_VALUE>"
    let mut client = ServiceBusClient::new(

    // Replace "<QUEUE-NAME>" with the name of your queue
    let mut sender = client
        .create_sender("<QUEUE-NAME>", ServiceBusSenderOptions::default())

    // Create a batch
    let mut message_batch = sender.create_message_batch(Default::default())?;

    for i in 0..3 {
        // Create a message
        let message = ServiceBusMessage::new(format!("Message {}", i));
        // Try to add the message to the batch
        if let Err(e) = message_batch.try_add_message(message) {
            // If the batch is full, an error will be returned
            println!("Failed to add message {} to batch: {:?}", i, e);

    // Send the batch of messages to the queue
    match sender.send_message_batch(message_batch).await {
        Ok(()) => println!("Batch sent successfully"),
        Err(e) => println!("Failed to send batch: {:?}", e),


1 Like