RabbitMQ tutorial - Routing
Routing
(using the Objective-C client)
Prerequisites
This tutorial assumes RabbitMQ is installed and running on
localhost
on the standard port (5672). In case you
use a different host, port or credentials, connections settings would require
adjusting.
Where to get help
If you're having trouble going through this tutorial you can contact us through the mailing list or RabbitMQ community Slack.
In the previous tutorial we built a simple logging system. We were able to broadcast log messages to many receivers.
In this tutorial we're going to add a feature to it - we're going to make it possible to subscribe only to a subset of the messages. For example, we will be able to direct only critical error messages to the log file (to save disk space), while still being able to print all of the log messages on the console.
Bindings
In previous examples we were already creating bindings. You may recall code like:
[q bind:exchange];
A binding is a relationship between an exchange and a queue. This can be simply read as: the queue is interested in messages from this exchange.
Bindings can take an extra routingKey
parameter. To avoid the
confusion with an RMQExchange publish:
parameter we're going to call it a
binding key
. This is how we could create a binding with a key:
[q bind:exchange routingKey:@"black"];
The meaning of a binding key depends on the exchange type. The
fanout
exchanges, which we used previously, simply ignored its
value.