@johnmmackey/amqp-persistent

    2.0.3 • Public • Published

    amqp-msrvlib

    Wrapper for ampqlib providing persistent connection to the AMQP server.

    Due to the use of ES6 features, this module requires Node.js V8 or above.

    Quickstart

    npm install @johnmmackey/amqp-persistent
    const { amqpPersistentConnection } = require('@johnmmackey/amqp-persistent');
     
    // Establish a connection to server
    // Server URI is taken from AMQP_URI environment variable.
    // If not set, defaults to 'amqp://localhost'
    amqpPersistentConnection.connect();
     
    // Alternately, a server can be specified:
    amqpPersistentConnection.connect('amqp://amqpserver.domain.com');

    amqpPersistentConnection is an instance of EventEmitter. Events:

    • debug: informational
    • ready: when connection is ready
    • failed: if connection drops

    Usage example:

        amqpPersistentConnection.on('debug', status => {
            console.log('AMPQ Connection debug:', status);
        });

    Core Methods

    A connection has the following core methods:

    • addConfig(f), where f is a function returning a promise. Example:
        amqpPersistentConnection.addConfig(async ch => {
            await ch.assertExchange('sillyex', 'fanout');
            await ch.assertQueue('sillyq');
            await ch.bindQueue('sillyq', 'sillyex', '');
            ch.consume('sillyq', msg => {
                myConsumerFunction(msg);
            }, { noAck: true });
        });
    • amqpPersistentConnection.ack(msg) - acknowledge a message (used in consumer functions)

    Keywords

    Install

    npm i @johnmmackey/amqp-persistent

    DownloadsWeekly Downloads

    1

    Version

    2.0.3

    License

    ISC

    Unpacked Size

    4.42 kB

    Total Files

    4

    Last publish

    Collaborators

    • johnmmackey