Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 25, 2024 via pnpm

amqplib 0.8.0

An AMQP 0-9-1 (e.g., RabbitMQ) library and client.
Package summary
Share
0
issues
2
licenses
15
MIT
1
ISC
Package created
21 Jun 2013
Version published
19 May 2021
Maintainers
2
Total deps
16
Direct deps
6
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
15 Packages, Including:
amqplib@0.8.0
bitsyntax@0.1.0
bluebird@3.7.2
buffer-more-ints@1.0.0
core-util-is@1.0.3
debug@2.6.9
isarray@0.0.1
ms@2.0.0
querystringify@2.2.0
readable-stream@1.1.14
requires-port@1.0.0
safe-buffer@5.1.2
safe-buffer@5.2.1
string_decoder@0.10.31
url-parse@1.5.10

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
inherits@2.0.4
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

6
All Dependencies CSV
β“˜ This is a list of amqplib 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
bitsyntax0.1.016.61 kBMIT
prod
bluebird3.7.2136.03 kBMIT
prod
buffer-more-ints1.0.05.54 kBMIT
prod
readable-stream1.1.1420.15 kBMIT
prod
safe-buffer5.2.19.74 kBMIT
prod
url-parse1.5.1016.61 kBMIT
prod

Visualizations

Frequently Asked Questions

What does amqplib do?

Amqplib is a library for creating AMQP 0-9-1 clients for Node.JS. It serves as an interface to interact with messaging platforms such as RabbitMQ. However, it's worth noting that amqplib does not implement AMQP 1.0 or AMQP 0-10. Its stability, API completeness, and extensive usage in production makes it an excellent choice for integrating AMQP-based messaging functionalities into Node.JS applications.

How do you use amqplib?

Amqplib can be integrated into a Node.JS application with the npm install amqplib command. It follows either a callback or promise/async API structure, depending on your preference. Here are sample usage examples for both:

For Callback API:

const amqplib = require('amqplib/callback_api');
const queue = 'tasks';

amqplib.connect('amqp://localhost', (err, conn) => {
  if (err) throw err;

  // Listener
  conn.createChannel((err, ch2) => {
    if (err) throw err;

    ch2.assertQueue(queue);

    ch2.consume(queue, (msg) => {
      if (msg !== null) {
        console.log(msg.content.toString());
        ch2.ack(msg);
      } else {
        console.log('Consumer cancelled by server');
      }
    });
  });

  // Sender
  conn.createChannel((err, ch1) => {
    if (err) throw err;

    ch1.assertQueue(queue);

    setInterval(() => {
      ch1.sendToQueue(queue, Buffer.from('something to do'));
    }, 1000);
  });
});

For Promise/Async API:

const amqplib = require('amqplib');

(async () => {
  const queue = 'tasks';
  const conn = await amqplib.connect('amqp://localhost');

  const ch1 = await conn.createChannel();
  await ch1.assertQueue(queue);

  // Listener
  ch1.consume(queue, (msg) => {
    if (msg !== null) {
      console.log('Recieved:', msg.content.toString());
      ch1.ack(msg);
    } else {
      console.log('Consumer cancelled by server');
    }
  });

  // Sender
  const ch2 = await conn.createChannel();

  setInterval(() => {
    ch2.sendToQueue(queue, Buffer.from('something to do'));
  }, 1000);
})();

These examples demonstrate basic usage of the amqplib library to produce (send) and consume (receive) messages from a queue.

Where are the amqplib docs?

The amqplib documentation is hosted on GitHub Pages, and can be accessed at https://amqp-node.github.io/amqplib/. Here you'll find a comprehensive guide to the library's API reference, tips on troubleshooting, and a variety of examples derived from the RabbitMQ tutorials. Users can also view the change log to keep track of updates and changes made to the library over time. From initial setup to more complex tasks, the documentation provides all the information you need to integrate and leverage amqplib effectively in your Node.JS projects.