'How to Handle received messages and any errors using python of Azure servicebus i want to receive message after one function
Question- How to Run complete_message() function at the end of program
with servicebus_client:
# get the Queue Receiver object for the queue
receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME, max_wait_time=5)
with receiver:
for msg in receiver:
print("Received: " + str(msg))
# complete the message so that the message is removed from the queue
receiver.complete_message(msg)
Solution 1:[1]
Generally calling the complete_message(...) function means the message has been read successfully and it declares the message processing to be successfully completed, removing the message from the queue.
For every message which we read from the queue should be removed after receiving successfully and we can call this complete_message() after reading every message and It's recommended to call this method after receiving each message from the servicebus queue and not at the end of all messages because the messages in Service Bus can be received either in peek lock mode or receive and delete mode.
When the message is received in peek lock mode, the message is not deleted from the queue.
But when it is received in receive and delete mode the message is automatically received and removed from the Queue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | RajkumarMamidiChettu-MT |
