Reputation: 199
In node, I am fetching azure service bus queue messages using the azure library here is my code.
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)
}
});
I am getting lockedMessage but I don't know how to release lock in this fetched message so other consumers can use that message and processed further.
I didn't find anything in azure documentation.
Upvotes: 0
Views: 1084
Reputation: 470
You have to use the unlockMessage method to release the lock you acquire during peekLock.
Quoting below from this link https://learn.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."
Upvotes: 1