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

Need help designing a specific use case: handle asynchronous tasks on the same resource across consumers #176

Open
booboothefool opened this issue Oct 17, 2018 · 0 comments

Comments

@booboothefool
Copy link

booboothefool commented Oct 17, 2018

                  |--> queue_for_resource1 - consumer1
exchange          |--> queue_for_resource2 - consumer2
                  |--> queue_for_resource3 - consumer3
                  |--> ...

queue_for_resource# needs to be dynamically generated where resource# is some unique id. Because of this, I can't just put it all in the topology config because I don't know how many or which ones I will need ahead of time. I assume should be dynamically generated because:

Only 1 consumer should be able to process from a queue for a resource at a time. This is because the tasks in the queue will eventually do calls that modify that particular resource e.g. in a database, so if 2 consumers try to process at the same time, the resource will lock and fail. I was looking at prefetch: 1, exclusive queue, and exclusive consumer, and while I'm not sure of the differences, I believe exclusive consumer is the solution?

I think the solution is a combination of:

  • addQueue - with unique resourceId as name
  • bindQueue
  • startSubscription - with exclusive for 1 consumer at a time???

Another concern is what happens if consumer1 is assigned to queue_for_resource1, but consumer1 goes down? Will another consumer, such as consumer2 automatically subscribe and pick up where it left off?

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

1 participant