noodlefrenzy / node-amqp10

amqp10 is a promise-based, AMQP 1.0 compliant node.js client
MIT License
134 stars 56 forks source link

Question: Is there a way to receive only one message at a time and leave the rest on the queue? #365

Open swilliams-a3digital opened 6 years ago

swilliams-a3digital commented 6 years ago

I am new to amqp10 and I use this code to receive messages:

amqpClient.createReceiver(queueName).then(r => { r.on('message', message => { let subscriberMessage = new SubscriberMessage(); subscriberMessage.body = message.body; this.handleMessage(subscriberMessage); });

this works great for most cases, but I noticed that if 100 messages come into the queue at once, r.on message will fire 100 times immediately and all results get processed at the same time.

I'm looking for a way to only have the receiver process one message at a time. I read the docs, but don't really understand how to make this happen. I'm hoping there is simple change I can make to the policy somewhere. Any guidance would be greatly appreciated.

amarzavery commented 6 years ago

This repo is not actively being maintained or supported. I would recommend using rhea which is actively supported and has lesser issues.

swilliams-a3digital commented 6 years ago

I figure it out with this. this.amqpClient.createReceiver(queueName, { creditQuantum : 1, attach: { receiverSettleMode: 1 } }).then(r => {

thanks for tip about this library being dead.