Azure / azure-service-bus

☁️ Azure Service Bus service issue tracking and samples
https://azure.microsoft.com/services/service-bus
MIT License
585 stars 781 forks source link

ReceiveDeferredMessageAsync Method - Failed to lock one or more specified messages. Either the message is already locked or does not exist (MessageNotFound) #415

Closed AnikethNagansurya closed 2 years ago

AnikethNagansurya commented 3 years ago

Description

                              await using var clientDel = new ServiceBusClient(queueConnectionString);

                            // create a receiver that we can use to receive and settle the message
                            ServiceBusReceiver receiverLog = clientDel.CreateReceiver(queueName);

                            // the received message is a different type as it contains some service set properties
                            ServiceBusReceivedMessage receivedMessage = await receiverLog.ReceiveDeferredMessageAsync(fetchedSequenceNumber).ConfigureAwait(false);

                            // complete the message, thereby deleting it from the service
                            await receiverLog.CompleteMessageAsync(receivedMessage);

Actual Behavior

  1. Returns exceptions "Failed to lock one or more specified messages. Either the message is already locked or does not exist (MessageNotFound)"
  2. Removes the message from queue before CompleteMessageAsync is invoked

Expected Behavior

  1. Should return deffered message w.r.t to the sequence number passed
  2. Consume the message and remove from queue be invoking CompleteMessageAsync
EldertGrootenboer commented 2 years ago

If this still occurs using the latest SDK, can please open a new issue.