AlexLordThorsen
AlexLordThorsen

Reputation: 8488

Rabbitmq binding exchange to exchange

I'm looking for a way to secure my websites messaging system so that users only get data they should have access to. With this in mind, I thought of a system where I have a master topic exchange which my server will send all messages to.

The web site holds a sessionId for each user. When a user is authenticated, another exchange is created with a name of sessionId. The client side user is allowed to bind to all exchanges other then the master. Since sessionID's are unique it would be very hard to guess another users sessionID and bind to get their messages.

each message will have a routing key of sessionID.destination. The client side will know all of the potential destinations.

To help visualize:

                            -> SessionID Exchange -> client
Server -> master Exchange | -> SessionID Exchange -> client
                            -> SessionID Exchange -> client

My question is two fold. Is it possible to bind an exchange to an exchange in rabbitmq? Also, has someone set up a system like this one previously? Rather, does anyone with experience on this topic already have a working system which I may use?

Thanks in advanced.

Upvotes: 2

Views: 6715

Answers (3)

Prakhyat
Prakhyat

Reputation: 1019

In case of single exchange and multiple queues bound, messages sent by client will reach via exchange to possible queues based upon bindings.Which means message from client will reach destination queue via exchange in one hop.

Consider a case where you want messages to be sent to possible destination queues based upon bindings, ALSO take more hops to different exchange and its queue bound. In such cases exchange to exchange binding will fit the purpose.

Binding queue to exchange is a costly process.Exchange to exchange binding is more flexible and a better scalability solution. Client can create its own private exchange and bind to special purpose exchange at the server. Exchange to exchange binding is better in performance and solves scalability issues.

Upvotes: 1

robthewolf
robthewolf

Reputation: 7624

Yes it is possible to bind and exchange to and exchange. You can even have different types of exchanges. You need to used channel.exchangeBind() instead of channel.queueBind(). But it works in a similar way.

I have a topic exchange bound to a fanout exchange in my system. I make sure to send a routing key with the messages sent to the fanout exchange. Its no effect at the fanout exchange level but when it gets routed to the topic exchange the routing key is then used to determine which queues it is sent to.

Upvotes: 5

AlexLordThorsen
AlexLordThorsen

Reputation: 8488

I found this blog which talked about something similar to my design. It's not quite the same thing, but it let's me know that it's at least possible.

http://blog.springsource.org/2011/04/01/routing-topologies-for-performance-and-scalability-with-rabbitmq/

Upvotes: 1

Related Questions