문제

How can I set the TTL for messages I put in the Azure queue, such that they don't last beyond 30 seconds using Node.js?

I can't seem to find any mention of Time To Live in the SDK for Node.js on Github.

도움이 되었습니까?

해결책

If you look at the documentation for createMessage on Github (https://github.com/WindowsAzure/azure-sdk-for-node/blob/master/lib/services/queue/queueservice.js), you'll notice that you can provide additional parameters to that operation. One of the parameter is messagettl. You would need to specify that parameter. See sample code below. Here the message will automatically expire after 30 seconds.

var azure = require('azure');
var queueService = azure.createQueueService("account", "key");
queueService.createQueueIfNotExists("dummy", function(error){
    if(!error){
        queueService.createMessage("dummy", "Hello world!", {messagettl: 30}, function(error){
    if(!error){
        console.log("Message Created");
    }
});
    }
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top