Trying to poll an Azure Service Bus Queue using a WebJob written in Node.js. I created 2 WebJobs. The first is on demand and sends 10 unique messages to the queue. The secon
Try using the amqp to read the messages off the azure service bus partitioned queue and this will work for a partitioned topic/queue and you don't even have to poll a lot.
const AMQPClient = require('amqp10').Client;
const Policy = require('amqp10').Policy;
const protocol = 'amqps';
const keyName = 'RootManageSharedAccessKey';
const sasKey = 'your_key_goes_here';
const serviceBusHost = 'namespace.servicebus.windows.net';
const uri = `${protocol}://${encodeURIComponent(keyName)}:${encodeURIComponent(sasKey)}@${serviceBusHost}`;
const queueName = 'partitionedQueueName';
const client = new AMQPClient(Policy.ServiceBusQueue);
client.connect(uri)
.then(() => Promise.all([client.createReceiver(queueName)]))
.spread((receiver) => {
console.log('--------------------------------------------------------------------------');
receiver.on('errorReceived', (err) => {
// check for errors
console.log(err);
});
receiver.on('message', (message) => {
console.log('Received message');
console.log(message);
console.log('----------------------------------------------------------------------------');
});
})
.error((e) => {
console.warn('connection error: ', e);
});
https://www.npmjs.com/package/amqp10