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

Allow to set queue name prefix #226

Open
gottfrois opened this issue May 9, 2016 · 4 comments
Open

Allow to set queue name prefix #226

gottfrois opened this issue May 9, 2016 · 4 comments

Comments

@gottfrois
Copy link
Contributor

I also would like your feedback on this. I'm in a situation where we use hutch in multiple services. Each consumers is namespaced under a consumer ruby module. We try to name our consumers based on what they actually do but i'm afraid of name collision.

So the idea would be to prefix all queues with some name, like our service name. Also, it would help to setup rabbitmq policies by pattern matching all queues that have their name starting by the service name.

What's your input on this?

@michaelklishin
Copy link
Member

Use separate vhosts?

@gottfrois
Copy link
Contributor Author

The issue by using seperate vhosts is that Service A publishes an event on vhost X, Service B consumes events on vhost Y. Not sure how you can configure rabbitmq to broadcast messages across vhosts.

@michaelklishin
Copy link
Member

Are your consumers reused between services? If not, it should be safe to include prefixes into queue names manually.

@gottfrois
Copy link
Contributor Author

gottfrois commented May 10, 2016

No each services define their set of consumers. The issues comes down to naming consumers and therefor rabbitmq queues.

Let's say Service A define a consumer called Consumers::CommandHandler and Service B also define a consumer named Consumers::CommandHandler. Since the consumers are in 2 different services, the implementation details would be different (2 different context) even though the consumer "handles a command".

To avoid this issue a simple solution is to name the consumers based on what they do instead of on what they consume.

Service A : Consumers::SendEmailToUserOnCommand
Service B : Consumers::CreateResourceXOnCommand

It also have the advantage of being easy to identify the intent of each consumers.

While this works fine, it's not helpful when you want to apply rabbitmq policies to all the queues of Service B. Let's say you want to set a TTL on each messages in Service B queues. You can use rabbitmq policies but you need a queue pattern to match against.

With a queue name prefix, it's easier: ^service_b:consumers.*$

Now, I know we can set queue name per consumer but what I was suggesting is a global config on hutch to prefix each queues with some string.

On Service B config/initializers/hutch.rb:

Hutch::Config.set :queue_prefix, "service_b"

Does that make sense?

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