Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amqplib-retry

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amqplib-retry

Retry failed attempts to consume a message, with increasing delays between each attempt.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
221
increased by18.82%
Maintainers
1
Weekly downloads
 
Created
Source

amqplib-retry

Retry failed attempts to consume a message, with increasing delays between each attempt.

NPM

Build Status

Installation (via npm)

$ npm install amqplib-retry --save

Usage

(function () {
  'use strict';

  var Promise = require('bluebird'),
    amqplib = require('amqplib'),
    retry = require('amqplib-retry'),
    CONSUMER_QUEUE = 'example-queue',
    FAILURE_QUEUE = 'example-queue.failure';

  Promise.resolve(amqplib.connect('amqp://localhost:5672'))
    .then(function (conn) {
      return conn.createChannel();
    })
    .tap(function (channel) {
      return Promise.all([
        channel.assertQueue(CONSUMER_QUEUE, {durable: false, autoDelete: true}),
        channel.assertQueue(FAILURE_QUEUE, {durable: false, autoDelete: true})
      ]);
    })
    .tap(function (channel) {

      var messageHandler = function (msg) {
        // no need to 'ack' or 'nack' messages
        // messages that generate an exception (or a rejected promise) will be retried
        console.log(msg);
      };

      channel.consume(CONSUMER_QUEUE, retry({
        channel: channel,
        consumerQueue: CONSUMER_QUEUE,
        failureQueue: FAILURE_QUEUE,
        handler: messageHandler
        //delay: function (attempts) { return 1000; /* milliseconds */ }
      }));

    });

}());

License

MIT License

Author

Lanetix (engineering@lanetix.com)

Keywords

FAQs

Package last updated on 04 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc