0
votes

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.

1
Are you using azure-sb node package or @azure/service-bus node package? I would like to say azure-sb but then const azure = require('azure'); is something you would use with @azure/service-bus package. - Gaurav Mantri
I am using this(npmjs.com/package/azure) node package - Jay Dadhaniya

1 Answers

1
votes

You have to use the unlockMessage method to release the lock you acquire during peekLock.

Quoting below from this 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."