Comments (4)
When you set prefetch to 50, you are telling RabbitMQ deliver messages concurrently until there are 50 unacknowledged messages for this consumer. By the time you have called channel.cancel(), Rabbit has already delivered 50 messages. Cancelling will only stop subsequent messages from being delivered.
To achieve what I think you want, you need to set the prefetch to 1. Then you probably don't need to cancel the consumer, since you will only be handling one message at a time. The alternative is to explicitly get a message from the channel. The documentation can be found here. The drawback is when the queue is empty, you will have to decide how frequently to poll.
from amqplib.
Hi @pastTenseVerb,
It looks like you are not setting a channel prefetch. This means that RabbitMQ will deliver all messages concurrently, hence the messages will have all been delivered before you cancel the consumer. Instead you need to either switch to using channel.get or set a channel prefetch.
from amqplib.
When I add a prefetch of 50, it does stop all 500 from getting consumed but I'm still consuming 50 after I call channel.cancel() so not much has changed. I can switch to using channel.get but are there any drawbacks to doing so?
Also do you think it's possible I'm getting false positives by running a rabbitMQ container locally? I'm sure channel.cancel works as intended since there aren't many issues brought up about it.
from amqplib.
OK to close @pastTenseVerb?
from amqplib.
Related Issues (20)
- Trailing dot in URL causes TLS failure HOT 2
- docs: channel api github page has broken top links HOT 2
- docs: confusing and inconsistent usage of terms "bork", "splode", "close" HOT 7
- global prefetch become 0 if per-consume prefetch set HOT 2
- ERR_SSL_EMS_NOT_ENABLED HOT 6
- How to determine if channel.ack() is successful? HOT 2
- CPU intensive controller prevents AMQP connection from receiving heartbeat, hence connections gets closed. HOT 2
- How to know if message is published ? HOT 6
- Aborting a Message Processing when RMQ Channel Closes HOT 8
- I'm encountering an "Unexpected close" error HOT 2
- Module not found: Can't resolve 'querystring' HOT 2
- Feature: Add support for AMQP 0.9.1 "update-secret" HOT 11
- 501 (FRAME-ERROR) - after indeterminate amount of large messages HOT 6
- Emits a acknowledge event. HOT 1
- Error: Unexpected close at succeed HOT 13
- Typo in the example code HOT 1
- Who calls accept()? HOT 3
- Consume large message. How do I resolve the problem that an Invalid frame occurs because the content is not read complete HOT 66
- first error message thrown by stream_socket_enable_crypto() is not propagated to caller HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amqplib.