3

I've got a service bus topic triggered function which gets triggered whenever some data is pushed to the topic.

The function looks something like this:

[FunctionName("funcGetServiceBusEntities")]
public async Task Run([ServiceBusTrigger("sbtopic", "sbsub", Connection = "ServiceBusConnectionString")]Message message, MessageReceiver messageReceiver, [DurableClient] IDurableOrchestrationClient starter, ILogger log)
{  
   // perform processing on the data

   //...

   //...

   // Complete since we don't want to process the message again
   await messageReceiver.CompleteAsync(message.SystemProperties.LockToken);

   //...
}

I' m not sure why I'm getting this error:

Microsoft.Azure.ServiceBus: The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue. Reference:ab88d42f-5fed-4392-983a-921cc6eab776, TrackingId:7664c851-9f29-4b4f-a334-4038e0921810_B11, SystemTracker:sb-dev:Topic:sbtopic|sbsub, Timestamp:2020-03-31T12:09:32.

Is the implementation of CompleteAsync wrong?

Nkosi
  • 235,767
  • 35
  • 427
  • 472
The Inquisitive Coder
  • 1,085
  • 3
  • 20
  • 43
  • Have you seen this https://stackoverflow.com/questions/28127001/the-lock-supplied-is-invalid-either-the-lock-expired-or-the-message-has-alread – Nkosi Mar 31 '20 at 14:54
  • When the message is be triggered, the message will be removed from the service bus topic. Any update? Can you mark my answer to end this question? Thanks:) – Cindy Pau Apr 10 '20 at 00:48

1 Answers1

2

This is what you faced now:

enter image description here

Please notice that after triggered the message will be removed. So you don't need to tag it and don't worry about process the message again. It has already been removed.

Cindy Pau
  • 13,085
  • 1
  • 15
  • 27