Web TippsUse custom web fonts in Google Sheets charts(08.09.2026 um 17:05 Uhr)
Web TippsIntroducing the new 1Password App for Google Chat(08.09.2026 um 18:02 Uhr)
Web TippsUse custom web fonts in Google Sheets charts(08.09.2026 um 17:05 Uhr)
Web TippsIntroducing the new 1Password App for Google Chat(08.09.2026 um 18:02 Uhr)

🔧 Programmierung 🕛 vor 2 Jahren 7 Min Lesezeit
0

Azure Service Bus 101: Introduction to Queues and Messaging

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

.



Throughout your reading, you will see how to:




  • Send messages in a queue,

  • Consume messages in a queue,

  • Send messages using topics,

  • Subscribe to a topic and receive messages,



Regarding the code, most of the calls will be non-blocking and therefore asynchronous; a good understanding of async is essential, you can find more info about it



In summary, a queue is:




  • A temporary storage warehouse for messages,

  • Messages are delivered upon the consumer's request,

  • The receiver consumes messages starting with the one that arrived first, following the First In First Out principle.



Example of Use

We have two services:




  • The first service creates users.

  • The second service handles notifications, sending emails and/or push notifications to our users after their creation.



In our example, it is possible to subscribe our notification service to the 'notification' queue, which receives messages such as 'UserCreated' with the property 'UserId = xxx'. This identifier will be used by the notification service to send a welcome email.





Azure Service Bus — Topics



Topics provide the ability to have a provider with multiple observers or consumers, each consumer having its own queue that feeds it.



and log in to your Azure account.



  • Create a new Service Bus namespace:




    1. Click on "+ Create a resource."

    2. Search for "Service Bus" and select it.









    • Review and deploy:


      • Review configuration details and initiate the deployment process.

      • Wait for the deployment to complete.





    waiting deployment





    • Access your Service Bus:


      • Once deployed, find your Service Bus namespace under "All resources."

      • Explore and manage your Service Bus, create queues, topics, or subscriptions as needed.
        service-bus panel





    Within your Service Bus namespace, you can create queues, topics, subscriptions, and manage various settings based on your application needs.

    Click on "Queues" or "Topics" to create a new queue or topic and set up subscriptions or rules according to your messaging requirements.



    Creating Queues




    CODE
    import { ServiceBusClient } from '@azure/service-bus';

    async function createQueue() {
    const connectionString = '<YOUR_CONNECTION_STRING>'; // Replace with your Service Bus connection string
    const queueName = '<YOUR_QUEUE_NAME>'; // Replace with your desired queue name

    const serviceBusClient = new ServiceBusClient(connectionString);

    try {
    const queueOptions = {
    // Define queue options if needed
    // For example:
    // defaultMessageTimeToLive: 60 // Message time-to-live in seconds
    };

    const queueDetails = await serviceBusClient.createQueue(queueName, queueOptions);
    console.log(`Queue "${queueDetails.queueName}" created successfully.`);
    } catch (error) {
    console.error('Error creating queue:', error);
    } finally {
    await serviceBusClient.close();
    }
    }

    // Call the function to create the queue
    createQueue();







    Sending a message




    CODE
    const { ServiceBusClient } = require('@azure/service-bus');

    async function sendMessageToQueue() {
    const connectionString = '<YOUR_CONNECTION_STRING>'; // Replace with your Service Bus connection string
    const queueName = '<YOUR_QUEUE_NAME>'; // Replace with your queue name

    const serviceBusClient = new ServiceBusClient(connectionString);

    try {
    const sender = serviceBusClient.createSender(queueName);
    const message = {
    body: 'Hello, Azure Service Bus!', // Replace with your message payload
    };

    await sender.sendMessages(message);
    console.log('Message sent successfully to the queue.');
    } catch (error) {
    console.error('Error sending message:', error);
    } finally {
    await serviceBusClient.close();
    }
    }

    // Call the function to send the message
    sendMessageToQueue();






    This JavaScript code uses the ServiceBusClient class from the @azure/service-bus package to create a sender for the specified queue and sends a message with a simple payload, and the ServiceBusClient package to create a sender for the specified queue.

    Adjust the message body or other properties as needed based on your requirements.



    Make sure to handle errors appropriately and ensure that your Azure account has the necessary permissions to send messages to the specified queue in the Service Bus namespace.



    This process sets up a basic Azure Service Bus namespace. From there, you can integrate it into your applications, set up messaging patterns, and utilize the Service Bus functionalities to facilitate communication between different components of your applications or services.






    Conclusion



    Throughout this article, we've covered the creation and receipt of messages within and from a queue.



    This service broadens the spectrum of possibilities significantly. One can envision utilizing queues within Azure Functions to trigger processes upon message receipt.



    I hope this article has allowed you to familiarize yourself with Azure Service Bus, and please leave a comment if you have any questions.

    Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
    ↗ Original-Artikel auf dev.to lesen
    Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    3 Quellen
    Use custom web fonts in Google Sheets charts
    2 Quellen
    Introducing the new 1Password App for Google Chat
    1 Quelle
    Context-aware access controls are available for Gemini Enterprise in the Admin console
    Ähnliche Beiträge
    🔍 Verwandte News

    Auch interessante Nachrichten Azure Service Bus 101: Introduction to Queues and Messaging

    Thematisch verwandte Begriffe: Azure, Service, Introduction, Queues · 6 Treffer

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...