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

Add Support for sharing rmq Queues across multiple Connections #126

Closed
chrisUsick opened this issue Sep 1, 2022 · 3 comments
Closed

Add Support for sharing rmq Queues across multiple Connections #126

chrisUsick opened this issue Sep 1, 2022 · 3 comments

Comments

@chrisUsick
Copy link

Hi!
I'm using rmq to implement a durable queue for my application. If I understand the library correctly, it intends for the user to create all new queues every time the application starts. This means that the connection and queues created only live for one run of the application. Furthermore, it means that 2 instances of the same application can't share the same queues - they can't publish or consume on the same queues.
Firstly, I'm seeking to ensure I understand that correctly.
Secondly, assuming that's correct, I'd like to implement the ability to:

  • have multiple instances of the app use the same connection
  • allow multiple queues to be opened to the same redis list

This would unlock the 2 capabilities I'm seeking:

  • have the queue persist over database restarts (assuming the DB was flushed to disk) and application restarts
  • have multiple instances of the application publishing to and consuming from a single queue

I'm working on a fork to experiment with this. My approach currently is to add the ability control whether or not a random string is added to the connection tag.

Feedback, context, reasoning for why this isn't currently support, and alternative approaches are all welcome.
I'm happy to create a PR if/when I'm successful if that would be appreciated.

@wellle
Copy link
Member

wellle commented Sep 1, 2022

Firstly, I'm seeking to ensure I understand that correctly.

This is not correct. Of course multiple instances of different services can work together in the same queue system. Each instance should use its own connection, but all connections can use the same queues. Just look at the examples in this repository:
https://github.com/adjust/rmq/blob/master/example/producer/main.go
https://github.com/adjust/rmq/blob/master/example/consumer/main.go

You can start both of these programs at the same time. The producer publishes to the things queue and the consumer consumes from that same things queue.

  • have multiple instances of the app use the same connection

Each instance has its own connection. But all of the connections can use the same queues.

  • have multiple instances of the application publishing to and consuming from a single queue

This is already supported. With each instance having their own connection.

@chrisUsick
Copy link
Author

Ah, thank you!
In my local tests my consumers were pulling each message that went into a queue, into the conumer's unacked queue. Since that consumer unacked queue is "namespaced" to a connection and since redis deletes a list's key once the list is empty, it appeared like there was no queue to consume from when I inspected redis.

I'm glad to know I'm wrong and the library functions as expected!
Great work on this library BTW, Thanks!

@wellle
Copy link
Member

wellle commented Sep 2, 2022

Thank you! ❤️

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