How to prevent duplicate SQS Messages?

前端 未结 6 1639
时光取名叫无心
时光取名叫无心 2021-01-30 03:10

What is the best way to prevent duplicate messages in Amazon SQS? I have a SQS of domains waiting to be crawled. before I add a new domain to the SQS I can check with the saved

6条回答
  •  庸人自扰
    2021-01-30 03:57

    You can use the VisibilityTimeout parameter:

    var params = { 
        VisibilityTimeout: 20,
        ...
    };
    
    sqs.receiveMessage(params, function(err, data) {});
    

    reference: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html

    VisibilityTimeout — (Integer)
    The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

提交回复
热议问题