如何使用 isPeekLock:true 释放对从 Azure 服务总线队列中获取的消息的锁定

How to release lock on fetched message from azure service bus queue using isPeekLock:true

在节点中,我正在使用 azure 库获取 azure 服务总线队列消息 这是我的代码。

const azure = require('azure');
const serviceBusService = azure.createServiceBusService();

serviceBusService.receiveQueueMessage('queueName', { isPeekLock: true }, (error, lockedMessage) => {
    if (error) {
      console.log('Error', error)
    } else {
      console.log('Message', lockedMessage)
    }
  });

我收到 lockedMessage,但我不知道如何释放此获取消息中的锁,以便其他消费者可以使用该消息并进一步处理。

我在 azure 文档中没有找到任何内容。

你必须使用 unlockMessage 方法来释放你在 peekLock 期间获得的锁。

下面引用自这个 link https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-nodejs-how-to-use-queues#how-to-handle-application-crashes-and-unreadable-messages

"Service Bus provides functionality to help you gracefully recover from errors in your application or difficulties processing a message. If a receiver application is unable to process the message for some reason, then it can call the unlockMessage method on the ServiceBusService object. it will cause Service Bus to unlock the message within the queue and make it available to be received again, either by the same consuming application or by another consuming application."