Wrapper for amqplib connection that reconnects on failure.
import {connect} from 'alpha-amqp-connection-wrapper';
connect('amqp://your.connection:1010/string?heartbeat=10')
.then((connection) => {
connection.channel;
connection.connection;
})
retry
- on connection retry with number of retry attemptconnection-error
- on internal connection errorconnected
- once connection establisheddisconnected
- obviouschannel
- once channel createderror
- hard fail once we reach maximum amount of retry attempts
connection
- any value provided to ampq.connectuseConfirmChannel
- Whether to use confirm channel - default falsereconnect
failAfter
- maximum amount of reconnect attempts - default no limitbackoffStrategy
- backoff strategy to use. Note that alpha-amqp-connection-manager exports "backoff" module so you don't need to have it defined in your local package.json in order to use it.
The library uses great debugFn package. Call your app with DEBUG env variable set in order to see debugFn messages.
DEBUG=alpha-amqp-connection-manager:*
Available as Typescript definition files