simple-rabbitmq-client

1.0.0 • Public • Published

Simple RabbitMQ client for node

Usage

const {
  actionConfigs,
  PythonServiceClient,
} = require('@scope.gg/simple-rabbitmq-client')

const rabbit = new SimpleRabbitClient(rabbitUrl, {
  [queueName]: {
    options: {
      durable: true,
      maxPriority: 4,
      arguments: {
        'x-message-deduplication': true,
        'x-cache-persistence': 'memory',
        'x-cache-size': 1e5,
        'x-cache-ttl': 2 * 60 * 60 * 1000,
      },
    },
  },
});

const init = async () => {
  const channel = await this.rabbit.getChannel();

  channel.on('error', () => {});

  await channel.checkQueue(this.pythonQueue);

  return this.rabbit.startConsuming();
}

// somewhere in the caller code
await channel.sendToQueue(
  queueName,
  Buffer.from(JSON.stringify(message)),
  {
    ... // options
  },
);

Readme

Keywords

Package Sidebar

Install

npm i simple-rabbitmq-client

Weekly Downloads

1

Version

1.0.0

License

UNLICENSED

Unpacked Size

3.73 kB

Total Files

5

Last publish

Collaborators

  • alextolmachevv