RabbitMQ - Create Exchange using the rabbitmqadmin command

This assumes you have downloaded and setup the rabbitmqadmin command line tool.

declare exchange can be used to create an exchange. In this example, an exchange named exchange001 is as a direct exchange.

rabbitmqadmin declare exchange --vhost=/ name=exchange001 type=direct

 

If the exchange is created, the following should be returned.

exchange declared

 

With a direct exchange, when the producer publishes a messages to the exchange with a routing key, the exchange must be bound to a queue with the exact same routing key. For example, if the producer publishes a message to exchange001 with routing key key001, then exchange001 would need to be bound to a queue with routing key key001.

With a topic exchange, when the producer publishes a messages to the exchange with a routing key, the exchange can be bound to one or more queues with a regular expression matching the routing key. For example, if the producer publishes a message to exchange001 with routing key key001, then exchange001 could be found to queues with a regular expression such as key.*.

With a headers exchange, the exchange will match one or all of the headers in the message to know which target queues the message should be routed to. For example, if the header exchange has arguments x-match: any and foo: bar, if the producer publishes a message to exchange001 with header foo: bar, then the message will be routed to the queues that are bound to the exchange. A routing key would not be used in the binding between the header exchange and queues.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 69617 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |