Giter Site home page Giter Site logo

Comments (4)

cressie176 avatar cressie176 commented on June 12, 2024 1

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.

cressie176 avatar cressie176 commented on June 12, 2024

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.

pastTenseVerb avatar pastTenseVerb commented on June 12, 2024

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.

cressie176 avatar cressie176 commented on June 12, 2024

OK to close @pastTenseVerb?

from amqplib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.