3.3.0 • Published 1 year ago

amqp-extension v3.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

AMQP Extension 🏰

npm version codecov Master Workflow Known Vulnerabilities semantic-release: angular

This is a library on top of the amqplib library and is meant to simplify the process of consuming & publishing queue messages.

Table of Contents

Installation

npm install amqp-extension --save

Usage

Publish

The publish method allows you to send messages quickly.

import { Client } from "amqp-extension";

const client = new Client({
    connectionOptions: 'amqp://<user>:<password>@<host>',
    exchange: {
        name: '<name>',
        type: 'topic'
    }
});

(async () => {
    await client.publish('<routing-key>', {
        foo: 'bar'
    });
})();

Consume

To consume a queue use the consume function.

import {
    Client,
    ConsumeMessage,
    ConsumeOptions,
} from "amqp-extension";

const client = new Client({
    connectionOptions: 'amqp://<user>:<password>@<host>',
    exchange: {
        name: '<name>',
        type: 'topic'
    }
});

(async () => {
    await client.consume('<routing-key>', {
        $any: async (message: ConsumeMessage) => {
            const content = message.content.toString('utf-8');
            const payload = JSON.parse(content);
            console.log(payload);
            // { type: 'resourceCreated', name: 'foo' }
        }
    });
})();

License

Made with 💚

Published under MIT License.

4.0.0-beta.3

1 year ago

4.0.0-beta.2

1 year ago

4.0.0-beta.1

1 year ago

3.3.0

1 year ago

3.2.0

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

3.0.0

1 year ago

2.0.2

1 year ago

2.0.1

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

2.0.0

2 years ago

1.0.5

3 years ago

1.0.2

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago