1.0.0 • Published 11 months ago

@eduzz/rabbit v1.0.0

Weekly downloads
71
License
MIT
Repository
-
Last release
11 months ago

Eduzz RabbitMQ Client

This is an simplified and padronized RabbitMQ Client for NodeJS

How to use

Create a connection

import { Connection } from '@eduzz/rabbit';

export const myRabbit = new Connection({
  dsn: 'amqp://...',
  exchange: 'my-exchange'
});

Send an message to an topic:

import { myRabbit } from './myRabbit';

const payload = {
  hello: 'world'
};

myRabbit.topic('some.topic').persistent().send({ payload });

Listen to one or multiple topics:

import { myRabbit } from './myRabbit';

myRabbit
  .queue('my.queue')
  .topic('some.topic')
  .topic('another.topic')
  .durable()
  .retryTimeout(60000)
  .listen(async data => {
    console.log(data);
    return true;
  });

Full working demo

import { Connection } from '@eduzz/rabbit';

const connection = new Connection({
  dsn: 'amqp://....',
  exchange: 'theExchange',
  exchangeType: 'topic',
  connectionName: 'my app'
});

// Listening some topic
await connection
  .queue('my.queue')
  .topic('my.topic')
  .durable()
  .retryTimeout(60000)
  .listen<string>(async msg => {
    console.log(msg);
    return true;
  });

// Publishing message
(async () => {
  const publisher = connection.topic('my.topic').persistent();

  setInterval(async () => {
    const payload = {
      number: Math.random() * 1000
    };

    publisher.send({
      payload
    });
  }, 1000);
})();

// Delaying Messages
connection.delayQueue('my.delay.queue').durable().from('from.topic').to('to.topic').timeout(5000).create();
1.0.0

11 months ago

1.0.0-beta.2

1 year ago

1.0.0-beta.3

1 year ago

1.0.0-beta.4

1 year ago

1.0.0-beta.5

1 year ago

1.0.0-beta.1

1 year ago

1.0.0-beta.10

12 months ago

1.0.0-next

1 year ago

1.0.0-beta.6

1 year ago

1.0.0-beta.7

1 year ago

1.0.0-beta.8

1 year ago

1.0.0-beta.9

12 months ago

0.4.0

1 year ago

0.3.0

1 year ago

0.3.1

1 year ago

0.2.1

2 years ago

0.2.0

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago

0.1.1

3 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3-1

4 years ago

0.0.3-0

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago