mycdc/lib/queue.js

18 lines
461 B
JavaScript
Raw Normal View History

2022-11-06 12:00:55 +00:00
module.exports = class Queue {
constructor(consumer, name, conf) {
Object.assign(this, {consumer, name, conf});
}
2022-11-06 12:00:55 +00:00
async consume() {
const channel = await this.consumer.amqpConn.createChannel();
channel.prefetch(this.conf.amqpPrefetch);
await channel.assertQueue(this.name, {
durable: true
});
this.channel = channel;
await channel.consume(this.name,
msg => this.onConsume(msg));
2022-11-06 12:00:55 +00:00
}
}