Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting "The lock supplied is invalid." error when I am trying to delete queue message using LockTocken

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')
like image 307
Moon Avatar asked Jun 19 '19 10:06

Moon


1 Answers

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.

like image 134
Sean Feldman Avatar answered Nov 14 '22 23:11

Sean Feldman