Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
amqplib-retry
Advanced tools
Retry failed attempts to consume a message, with increasing delays between each attempt.
amqplib-retry
Retry failed attempts to consume a message, with increasing delays between each attempt.
$ npm install amqplib-retry --save
var Promise = require('bluebird')
var amqplib = require('amqplib')
var retry = require('amqplib-retry')
var CONSUMER_QUEUE = 'example-queue'
var 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 */ }
}))
})
channel (required): Amqplib channel. See: connection.createChannel()
consumerQueue (required): Name of the queue that holds the amqp messages that need to be processed.
delay (optional): Delay in milliseconds between retries. Default: Math.pow(2, <# of attempts>)
failureQueue (optional): Name of the queue that holds the amqp messages that could not be processed in spite of the retries. Default: <consumerQueue>.failure
handler (required): Set up a consumer with a callback to be invoked with each message.
FAQs
Retry failed attempts to consume a message, with increasing delays between each attempt.
We found that amqplib-retry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.