1.0.0 • Published 2 years ago

simple-rabbitmq-client v1.0.0

Weekly downloads
-
License
UNLICENSED
Repository
gitlab
Last release
2 years ago

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
  },
);
1.0.0

2 years ago