Azure SDK causes Node.js service bus call to run slow

Posted by PazoozaTest Pazman on Stack Overflow See other posts from Stack Overflow or by PazoozaTest Pazman
Published on 2012-08-23T02:32:16Z Indexed on 2012/09/07 21:38 UTC
Read the original article Hit count: 353

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about node.js

Related posts about Azure