I am using python langauge to send & receive messages using Azure bus service queue.
I am getting "The lock supplied is invalid.Either the lock expired, or the message has already been removed from the queue" when deleting message from queue using below code.
sbs.delete_queue_message('taskqueue',5,'ef4e2189-bfef-42ac-ba09-7fd20287f6a9') sbs.delete_queue_message('taskqueue','SequenceNumber','LockToken')
from azure.servicebus.control_client import ServiceBusService, Message, Topic, Rule, DEFAULT_RULE_NAME
key_name = '###############' # SharedAccessKeyName from Azure portal
key_value = '####################' # SharedAccessKey from Azure portal
service_namespace = '###########'
sbs = ServiceBusService(service_namespace,shared_access_key_name=key_name,shared_access_key_value=key_value)
msg = sbs.receive_queue_message('taskqueue')
sbs.delete_queue_message('taskqueue',5,'ef4e2189-bfef-42ac-ba09-7fd20287f6a9')
The lock can expire if the message is processed longer than the MaxLockDuration
specified for the queue. Check what value for taskqueue
queue is and what's the duration of your message processing since the moment you've received it and till invocation of delete_queue_message()
.
An additional consideration is prefetch, but I'm not sure if it's enabled for the Python client or not. Worth verifying that it's either set to zero or is not causing messages to lose locks while waiting for processing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With