0.8.1 • Published 3 years ago

ts-amqp v0.8.1

Weekly downloads
109
License
MIT
Repository
-
Last release
3 years ago

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();
        }
    })
)
0.8.1

3 years ago

0.7.6

5 years ago

0.7.5

5 years ago

0.7.4

5 years ago

0.7.3

5 years ago

0.7.2

5 years ago

0.7.0

5 years ago

0.6.23

5 years ago

0.6.22

5 years ago

0.6.21

5 years ago

0.6.20

5 years ago

0.6.19

5 years ago

0.6.18

5 years ago

0.6.17

5 years ago

0.6.16

5 years ago

0.6.15

5 years ago

0.6.14

5 years ago

0.6.13

5 years ago

0.6.12

5 years ago

0.6.11

5 years ago

0.6.10

5 years ago

0.6.9

5 years ago

0.6.8

5 years ago

0.6.7

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.3.0

5 years ago

0.2.3

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago