0

I want to read all messages from azure service bus using python. Currently it fetch only one message.

from azure.servicebus.control_client import ServiceBusService, Message, Topic, Rule, DEFAULT_RULE_NAME

    bus_service = ServiceBusService(
        service_namespace='<NameSpace>',
        shared_access_key_name='<KeyName>',
        shared_access_key_value='<ConnectionString>')

msg = bus_service.receive_subscription_message('topic', 'msglist', peek_lock=True)
print(msg.body)

How can I get all the message in bulk from the topic with python 3

1
  • wanted to read all message in bulk Commented Feb 13, 2020 at 9:53

1 Answer 1

0

This is possible by using a Receiver object which supports batch operations. Refer this sample which showcases how to get this object for a subscription.

To guarantee you get batches of messages, you have to set the prefetch argument of get_receiver() to your batch size and consequently the max_batch_size argument of fetch_next() to the same.

Sign up to request clarification or add additional context in comments.

3 Comments

the sample to showcase receiver object is not available
Thanks! Updated the link.
Thanks for updating the link :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.