2.0.2 • Published 5 years ago

@dekproject/rabbitmq v2.0.2

Weekly downloads
12
License
MIT
Repository
github
Last release
5 years ago

@dekproject/rabbitmq

RabbitMQ interface plugin for DEK

What does this plugin do?

  • Control configuration for connection to RabbitMQ in production development mode in a simplified way with dotenv
  • Performs connection implementation along the lines ES6 being pre requirement to start the project

Instalation

To install the bootstrap we recommend using the CLI

$ yarn add @dekproject/rabbitmq --save

In the .env file add the following settings

RABBITMQ_HOST=localhost
RABBITMQ_PORT=5672

Usage

Using in the standard DEK skeleton

import { $, rabbitmq } from "@dekproject/scope";

$.wait("rabbitmq").then(() => {
    let connection = rabbitmq();

    connection.on("connect", () => {
        console.log("Connected!");
    });
    
    connection.on("disconnect", () => {
        console.log("Disconnected.");
    });

    let channelWrapper = connection.createChannel({
        json: true,
        setup: (channel) => {
            return Promise.all([
                channel.assertQueue("hello", { exclusive: true, autoDelete: true }),
                channel.prefetch(1),
                channel.consume("hello", (msg) => {
                    console.log(" [x] Received '%s'", msg.content.toString());
                    channel.ack(msg);
                }, { noAck: false })
            ]);
        }
    });

    channelWrapper.waitForConnect().then(() => {
        console.log("Listening for messages");
        channelWrapper.sendToQueue("hello", { hello: "world" });
    });     
}).catch((err) => {
    console.log(err);
    process.exit(-1);
});
2.0.2

5 years ago

1.5.1

5 years ago

2.0.1

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.3.3

5 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago