@prismamedia/amqp-client
TypeScript icon, indicating that this package has built-in type declarations

6.0.1 • Public • Published

AMQP Client

About

This module aims to ease the communication with a broker using the AMQP protocol, it provides some low-level tools.

Getting started

Prerequisites

This module requires Node 14 and a connection to an AMQP broker

Installation

import Client from '@prismamedia/amqp-client';
// or : Client = require('@prismamedia/amqp-client');

Configuration

const client = new Client('amqp://rabbitmq/');

Usage

const payload = { ... };

try {
  await client.publish('', 'queue_name', payload);
} catch (err) {
  // Handle error
}
try {
  const consumerId = await client.consume(
    'queue_name',
    (message, payload, ack) => {
      // Do what you want with the full AMQP message or with the Object payload

      ack();
    },
  );

  // [...]

  await client.stopConsumer(consumerId, true);
} catch (err) {
  // Handle error
}

/@prismamedia/amqp-client/

    Package Sidebar

    Install

    npm i @prismamedia/amqp-client

    Weekly Downloads

    2

    Version

    6.0.1

    License

    MIT

    Unpacked Size

    89.7 kB

    Total Files

    25

    Last publish

    Collaborators

    • prismamedia
    • yvann