Socket
Book a DemoInstallSign in
Socket

ts-amqp

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-amqp

An AMQP client library in pure TypeScript

0.8.1
latest
npmnpm
Version published
Weekly downloads
61
Maintainers
1
Weekly downloads
 
Created
Source

AMQP 0-9-1 client library for Node

ts-amqp is a modern library for communicating with AMQP 0-9-1 servers (e.g. RabbitMQ) from NodeJS applications. It is built with TypeScript and heavily uses Node's streams.

Install

npm i ts-amqp

Examples

For publishing a JSON message to an exchange:

const conn = new Connection({
    maxRetries: 30,
    retryDelay: 1000
});

await conn.start();

const ch = await conn.channel();

await ch.declareQueue({
    name: 'movies',
    durable: true,
    auto_delete: false,
    exclusive: false,
    arguments: {}
});

ch.json.write({
    routing_key: 'movies',
    body: {
        message: 'Hello, World!'
    }
});

await conn.close();

For consuming from a queue:

const conn = new Connection({
    maxRetries: 30,
    retryDelay: 1000
});

await conn.start();
const ch = await conn.channel();

await ch.declareQueue({
    name: 'movies',
    durable: true,
    auto_delete: false,
    exclusive: false,
    arguments: {}
});

const consumer = await ch.basicConsume('movies');

consumer.pipe(
    new Transform({
        objectMode: true,
        transform(chunk, _encoding, cb) {
            console.log(chunk.body.toString('utf-8'))
            cb();
        }
    })
)

Keywords

amqp

FAQs

Package last updated on 07 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.