Azure SDK causes Node.js service bus call to run slow
- by PazoozaTest Pazman
I am using this piece of code to call the service bus queue from my node.js server running locally using web matrix, I have also upload to windows azure "web sites" and it still performs slowly.
var sb1 = azure.createServiceBusService(config.serviceBusNamespace, config.serviceBusAccessKey);
sbMessage = {
"Entity": {
"SerialNumbersToCreate": '0',
"SerialNumberSize": config.usageRates[3],
"BlobName": 'snvideos' + channel.ChannelTableName,
"TableName": 'snvideos' + channel.ChannelTableName
}
};
sb1.getQueue('serialnumbers', function(error, queue){
if (error === null){
sb1.sendQueueMessage('serialnumbers', JSON.stringify(sbMessage), function(error) {
if (!error)
res.send(req.query.callback + '({data: ' + JSON.stringify({ success: true, video: newVideo }) + '});');
else
res.send(req.query.callback + '({data: ' + JSON.stringify({ success: false }) + '});');
});
}
else res.send(req.query.callback + '({data: ' + JSON.stringify({ success: false }) + '});');
});
It can be up to 5 seconds before the server responds back to the client with the return result. When I comment out the sb1.getQueue('serialnumbers', function(error, queue){ and just have it return without sending a queue message it performs in less than 1 second. Why is that? Is my approach to using the azure sdk service bus correct?
Any help would be appreciated.