Skip to content
Advertisement

Azure ServiceBus using async/await in Python seems not to work

I’m trying to read messages from Azure ServiceBus Topics using async/await and then forward the content to another application via HTTP. My code is simple:

JavaScript

I want to look for messages (forever) from various topics and when a message arrives send the POST. I import the aio package from azure which should work in an async way. After many attempts, the only solution I got is this with while True and setting the timeout=1. This is not what I wanted, I’m doing it sequentially.

azure-servicebus version 0.50.3.

This is my first time with async/await probably I’m missing something…
Any solution/suggestions?

Advertisement

Answer

Here’s how you’ll do it with the latest major version v7 of servicebus Please take a look a the async samples to send and receive subscription messages https://github.com/Azure/azure-sdk-for-python/blob/04290863fa8963ec525a0b2f4079595287e15d93/sdk/servicebus/azure-servicebus/samples/async_samples/sample_code_servicebus_async.py

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement