amqp-producer

1.0.5 • Public • Published

AMQP Producer wrapper for emails

Package is able to connect to AMQP server and send messages to queue. Messages will be send as encoded JSON. The main approach is to send encoded JSON as message to queue in which it should be decoded and send an email based on given JSON

Usage

const {MailerProducerService} = require('amqp-producer');

// Create mailerProducer instance
const mailerProducerConfig = [
    'amqp',
    'localhost',
    5672,
    'guest',
    'guest',
    '/',
    'email_queue'
];
const mailerProducer = new MailerProducerService(...mailerProducerConfig);


const start = async () => {
    // Start mailProducer
    await mailerProducer.start();
    
    // Send message to queue 
    const emailConfig = [
        'user@example.com',
        ['admin1@example.com', 'admin2@example.com'],
        'My Subject',
        'My Text'
    ];
    mailerProducer.sendEmailMsg(...emailConfig);
    
    // Stop mailProducer 
    mailerProducer.stop();
};

start();

API

MailerProducerService

An implementation of AMQP Producer

Kind: global class

new MailerProducerService(protocol, hostname, port, username, password, vhost, queue)

Param Type
protocol string
hostname string
port number
username string
password string
vhost string
queue string

mailerProducerService.start() ⇒ Promise.<void>

Setup connection, channel and queue

Kind: instance method of MailerProducerService

mailerProducerService.stop()

Close connection

Kind: instance method of MailerProducerService

mailerProducerService.sendEmailMsg(to, cc, subject, text)

Send email msg to queue

Kind: instance method of MailerProducerService

Param Type
to string
cc Array.<string>
subject string
text string

Readme

Keywords

none

Package Sidebar

Install

npm i amqp-producer

Weekly Downloads

1

Version

1.0.5

License

ISC

Unpacked Size

43.2 kB

Total Files

13

Last publish

Collaborators

  • yegor_heiz