Python Azure Service Bus Not retrieving messages from queue


Im trying to use python azure service bus client to constantly check a queue for new messages that contains process Id. For some reason, everytime i initialize the azure service bus client it runs for a couple of seconds then output the following message: Process finished with exit code -1073741819 (0xC0000005)

. Ive double checked my queue names and everything but I cannot understand what the issue is.

with servicebus_client:
    receiver = servicebus_client.get_queue_receiver( queue_name=CALC_REQUEST_QUEUE)
    print( "state 1" )
    with receiver:
        for msg in receiver:
            calc_request = json.loads( str( msg ) )
            processing_identifier = calc_request.get( 'processingIdentifier', None )
            print( "Received: " + str( processing_identifier ) )
            calc_config = fetch_calc_configuration( processing_identifier )
            calc_response = invoke_capsule_summary_processing(calc_config)
asked on Stack Overflow Jan 7, 2021 by lmomoh

1 Answer


If you just want to pull new messages from some queue continuously,try This :

import asyncio
from asyncio.tasks import sleep
from azure.servicebus.aio import ServiceBusClient


async def main():
    servicebus_client = ServiceBusClient.from_connection_string(conn_str=CONNECTION_STR)

    async with servicebus_client:
        receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME)
        async with receiver:
            received_msgs = await receiver.receive_messages(max_message_count=10, max_wait_time=5)
            for msg in received_msgs:
                await receiver.complete_message(msg)

loop = asyncio.get_event_loop()
while True : 
    #each 10 seconds to pull messages from queue.
    print('pull messages...')

Result: enter image description here

answered on Stack Overflow Jan 8, 2021 by Stanley Gong

User contributions licensed under CC BY-SA 3.0