18 lines
461 B
JavaScript
18 lines
461 B
JavaScript
module.exports = class Queue {
|
|
constructor(consumer, name, conf) {
|
|
Object.assign(this, {consumer, name, conf});
|
|
}
|
|
|
|
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));
|
|
}
|
|
}
|