@casestack/queueball v1.6.0
Queueball
A simple RabbitMQ-based work queue
Example
const { Consumer, Producer } = require('@casestack/queueball');
const config = {
rabbitmqUrl: 'amqp://guest:guest@localhost:5672',
name: 'example',
};
async function example() {
const producer = new Producer(config);
const consumer = new Consumer(config);
await Promise.all([producer.start(), consumer.start()]);
consumer.processJob = job => console.log(job.payload.exampleKey);
producer.enqueue({ exampleKey: 'example' });
}
example();
Connection Issues
If the producer or consumer cannot initially connect, the start()
method will throw an error. Once an initial connection is established, you can use the isConnected()
method to check on the status.
This is more set up to work alongside /health
checks, but may in the future be extended to emit events when a connection issue happens. A simple workaround for retries would just be use setInterval
and, if isConnected()
returns false, attempt to call start()
again.
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago