Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to limit the size of the async.queue? #1950

Closed
iamashay opened this issue Mar 16, 2024 · 3 comments
Closed

Is there any way to limit the size of the async.queue? #1950

iamashay opened this issue Mar 16, 2024 · 3 comments

Comments

@iamashay
Copy link

Is there any way to limit the size of the async.queue such that if items pushed into it exceed the maximum limit, it will throw an error? I have a RabbitMQ queue which has GitHub URLs that would be used to call a function which initializes Docker containers to process (build) them. At max, I want to have 2 containers to be created. That's why I would want the async.queue to throw an error on reaching max limit so that the URL message could go back to the RabbitMQ.

@thib3113
Copy link

@iamashay => you can read .length() on queue ? and so throw if the number returned is too high ?

Also, why not just using rabbitMQ ? tell rabbitMQ you just want two tasks in the same time (prefetch if I remember ?) ? and ack when task finish to get next one ?

@iamashay
Copy link
Author

@thib3113 , I read that I could make use of dead letter exchange feature to do this. Since I'm still new to RabbitMQ, I found it difficult to implement. For now, I'm using a semaphore library which takes care of running the function that runs docker instance at most 2 times, according to my requirement.

@thib3113
Copy link

@iamashay you can also use ack / nack ? and so the messages will go back in the current queue ? ( I don't remember setting this specifically ? https://www.rabbitmq.com/docs/nack )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants