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

Consider using BRPOPLPUSH #68

Closed
wyxloading opened this issue Aug 12, 2019 · 1 comment
Closed

Consider using BRPOPLPUSH #68

wyxloading opened this issue Aug 12, 2019 · 1 comment

Comments

@wyxloading
Copy link

rmq/queue.go

Line 332 in 507bf31

value, ok := queue.redisClient.RPopLPush(queue.readyKey, queue.unackedKey)

consume now call LLEN && RPOPLPUSH to gain queue message from redis.
BRPOPLPUSH can get rid of that LLEN call, should be more efficient.

@wellle
Copy link
Member

wellle commented May 4, 2020

I'm changing it right now to just use RPOPLPUSH until either the delivery channel is full or the source redis list is empty (RPOPLPUSH return (nil)). That way we get rid of LLEN.

I did consider using BRPOPLPUSH but there seems to be a problem. If the queue is empty and no new deliveries get produced, if the consumer is blocked on PRPOPLPUSH and calls queue.StopConsuming() (from a different goroutine), then we don't get a chance to check the consumingStopped value inside of consume() and will remain blocked forever.

For that reason I'm closing this issue. Thanks for the suggestion though! 🙌

@wellle wellle closed this as completed May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants