simple-rabbitmq-client
v1.0.0
Published
Simple RabbitMQ client
Downloads
1
Readme
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
},
);