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

[watermill-amqp] It is not possible to generate queue bindings from topic #305

Open
devinmarder opened this issue Oct 29, 2022 · 0 comments · May be fixed by ThreeDotsLabs/watermill-amqp#19

Comments

@devinmarder
Copy link

devinmarder commented Oct 29, 2022

It does not seem like it is possible to generate queue bindings from the topic

The amqp.Config allows providing a function to generate a queue binding

QueueBind: QueueBindConfig{
	GenerateRoutingKey: func(topic string) string {
		return topic
	},
},

This seems to imply that the topic that is being subscribed to will be bound to the queue with the generated binding key, but this doesn't actually seem possible, even with a custom implementation of the topology builder.

The default topology builder passes the generated queue to that function, not the topic. The TopologyBuilder interface does not accept the topic as an argument and the binding key is not being generated beforehand and passed in like the exchangeName and queueName:

type TopologyBuilder interface {
	BuildTopology(channel *amqp.Channel, queueName string, exchangeName string, config Config, logger watermill.LoggerAdapter) error
	ExchangeDeclare(channel *amqp.Channel, exchangeName string, config Config) error
}

I see a few options here:

  • add the topic to the buildTopology function signature (and even remove the queue and exchange parameters since they can already be generated from the topic and the Config
  • precompute the binding key and pass it in like the other parameters

This would allow for more customizable and dynamic topologies, utilizing wildcard matching on topic exchanges as well as more intuitive configurations.

An example would be to have an exchange which accepts topics as the routing key and then subscribers can subscribe to that on their own queue, and can even subscribe to a subset of those messages using wildcards. This seems like an example of how rabbitmq/amqp is typically used, but doesn't seem possible with the current watermill amqp implementation.

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

Successfully merging a pull request may close this issue.

1 participant