SpinGo / op-rabbit

The Opinionated RabbitMQ Library for Scala and Akka
Other
232 stars 73 forks source link

Fanout exchange- help needed #81

Closed guymaor86 closed 8 years ago

guymaor86 commented 8 years ago

Hi, I would like to use a fanout exchange and not a topic exchange, but the default configuration is by topic. I didn't understand how to do it from the documentation. In addition, how do I bind my queue to a fanout exchange rather than a topic exchange? Looks like this library is very 'topic' oriented. What I'm trying to achieve is the Pub/Sub example from the rabbitMQ site. I would like to do something like: channel.exchangeDeclare("logs", "fanout"); channel.queueBind(queueName, "logs", "");

Thank you

juanpavergara commented 8 years ago

You can find a simple example of publishing to a fanout topic here https://github.com/SpinGo/op-rabbit/blob/master/core/src/test/scala/com/spingo/op_rabbit/BindingSpec.scala#L68

The topology (exchange declarations and queue bindings) is created with the Subscription.

If you want to declare the topology from the producers (maybe because they are gonna begin producing messages before any subscription take place) you can extend com.spingo.op_rabbit.MessageForPublicationLike just like in https://github.com/SpinGo/op-rabbit/blob/master/core/src/test/scala/com/spingo/op_rabbit/helpers/DeleteQueue.scala#L7

I have done it and it works like a charm.