Giter VIP home page Giter VIP logo

azure_service_bus_sender_receiver's Introduction

Azure_service_bus_sender_receiver

These snippets allow creating a service bus namespace, write sample messages to it and read them

Prerequisites

These snippets require a linux environment, python3, Azure Service Bus python SDK and Azure CLI installed. If you have those already installed, go to the next section. For installing the Azure az CLI, please refer to the Azure Documentation.
Additionally, you would need to install additional packages with the following snippet:

sudo apt-get update -y
sudo apt-get install python3-pip -y
pip3 install azure-servicebus

Once installed, perform account login using az login

Creating an Azure service bus (Optional)

You can use the scripts provided for writing and reading from an existing service bus and topic, but the following script would create a test environment. You need to provide the subscription id as parameter and have executed previously az login to this very subscription.

 ./0_create_service_bus.sh 11111111-2222-3333-4444-55555555555 
Subscription set to 11111111-2222-3333-4444-55555555555
Creating RG service-bus-demo-rg in region westeurope
{
  "id": "/subscriptions/11111111-2222-3333-4444-55555555555/resourceGroups/service-bus-demo-rg",
  "location": "westeurope",
  "managedBy": null,
  "name": "service-bus-demo-rg",
  "properties": {
    "provisioningState": "Succeeded"
    .......

Sending sample messages to a service bus

If you have created the environment with the script 0_create_service_bus.sh, the message delivery script does not need additional parameters.

 ./1_service_bus_sender.sh  
Initialized connection to service bus service-bus-demo-sb-namespace on topic service-bus-demo-sb-topic at 2020-04-10 15:59:42.774624
  Sending message b'Msg 0 at 2020-04-10 15:59:42.774983' 
  Sending message b'Msg 1 at 2020-04-10 15:59:48.323102' 
  Sending message b'Msg 2 at 2020-04-10 15:59:48.430927' 
  Sending message b'Msg 3 at 2020-04-10 15:59:48.539948' 
  Sending message b'Msg 4 at 2020-04-10 15:59:48.648204' 

Additionally it can send sample messages to any service bus topic overriding default parameters, such as resource group, service bus namespace name and key.

./1_service_bus_sender.sh -h  
Usage: cmd [-n service_bus_namespace_name] [-g resource_group] [-k key_value] [-t topic]

Receiving messages from a service bus

If you have created the environment with the script 0_create_service_bus.sh, the script for receiving messages does not need additional parameters.

  ./2_service_bus_receiver.sh  
Initialized connection to service bus service-bus-demo-sb-namespace on topic service-bus-demo-sb-topic at 2020-04-10 16:05:10.806744
  Recieved message: b'Msg 0 at 2020-04-10 15:59:42.774983'
  Recieved message: b'Msg 1 at 2020-04-10 15:59:48.323102'
  Recieved message: b'Msg 2 at 2020-04-10 15:59:48.430927'
  Recieved message: b'Msg 3 at 2020-04-10 15:59:48.539948'
  Recieved message: b'Msg 4 at 2020-04-10 15:59:48.648204'

Additionally it can receive messages to any service bus topic overriding default parameters, such as resource group, service bus namespace name and key.

./2_service_bus_receiver.sh -h 
Usage: cmd [-n service_bus_namespace_name] [-g resource_group] [-k key_value] [-t topic]

azure_service_bus_sender_receiver's People

Contributors

seryiogonzalez avatar siyito avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.