npm.io
1.1.4 • Published 3 years ago

@clickheredigital/amqp

Licence
MIT
Version
1.1.4
Deps
1
Size
12 kB
Vulns
0
Weekly
0

AMQP

This library provides a shortcut for interacting with an AMQP-based message queue (RabbitMQ, for example).

Getting Started

Installation

npm i @clickheredigital/amqp
Usage
import { Publisher } from "./src";

(async () => {
  const pub: Publisher = new Publisher("amqp://localhost");

  try {
    // initialize the connection
    await pub.connect();

    // send a message to the AMQP message queue
    // the send function takes optional parameters `queueOpts` and `messageOpts`
    await pub.send("test", JSON.stringify({ message: "hello world" }));
  } catch (error) {
    console.error(error);
  } finally {
    // close the connection
    await pub.close();
  }
})();

Keywords