我尝试按照http://www.windowsazure.com/en-us/documentation/articles/storage-nodejs-how-to-use-queues/
进行操作我的代码: -
var AZURE = require('azure');
function TestQueue(QueueName)
{
var queueService = AZURE.createQueueService(); // error occurred at this line
queueService.createQueueIfNotExists(QueueName, function(error){
if(!error)
{
console.log("ok");
RESPONSE.send(200, { Message: "ok", Status: "ok" });
}
else
{
console.log("error: "+error);
RESPONSE.send(200, { Message: "error", Status: "error" });
}
});
}
错误讯息: -
错误讯息: -
NoMatchError:提供的设置{“blobendpoint”:“https://undefined.blob.core.windows.net”,“tableendpoint”:“https://undefined.table.core.windows.net”,“queueendpoint”:“https://undefined.queue.core.windows.net”}未完成。< / p>
请注意,有azure存储队列和azure服务总线队列。我需要服务总线队列。这样我就可以调用queueService.peekMessages()了。我的目标是获取队列消息而不从队列中删除消息。
我在另一个帖子@ Error when call azure.createQueueService()中问了同样的问题,它与2个不同的队列内容混在一起。最终我没有得到答案。希望这次得到答案。谢谢你!
答案 0 :(得分:0)
var azure = require('azure');
var namespace = 'YOUR-NAMESPACE-GOES-HERE';
var key = 'YOUR-KEY-GOES-HERE';
var issuer = 'owner'
var acs = namespace + '-sb';
var host = namespace + '.servicebus.windows.net';
var authProv = null;
var serviceBusService = azure.createServiceBusService(namespace, key, issuer, acs, host, authProv);
var queueName = 'nodequeue';
console.log('Connecting...');
serviceBusService.createQueueIfNotExists(queueName, function(error){
if(error){
console.log('ERROR: ' + error);
return;
}
console.log('Connected, receiving...');
serviceBusService.receiveQueueMessage(queueName, { isPeekLock: true },function(error, msg){
if(error){
console.log('ERROR: ' + error);
return;
}
console.log('Received:');
console.dir(msg);
});
});