I am not able to figure out the actual scenarios of using different exchange types provided in RabbitMQ.
Exchange is entity defined in AMQP protocol. See AMQP concepts at RabbitMQ tutorial:
A direct exchange delivers messages to queues based on the message routing key. A direct exchange is ideal for the unicast routing of messages.
A fanout exchange routes messages to all of the queues that are bound to it and the routing key is ignored. Fanout exchanges are ideal for the broadcast routing of messages. Massively multi-player online (MMO) games can use it for leaderboard updates or other global events; Sport news sites can use fanout exchanges for distributing score updates to mobile clients in near real-time; Distributed systems can broadcast various state and configuration updates; Group chats can distribute messages between participants using a fanout exchange (although AMQP does not have a built-in concept of presence, so XMPP may be a better choice).
Topic exchanges route messages to one or many queues based on matching between a message routing key and the pattern that was used to bind a queue to an exchange. Example uses: Distributing data relevant to specific geographic location, for example, points of sale; Background task processing done by multiple workers, each capable of handling specific set of tasks; Stocks price updates (and updates on other kinds of financial data); News updates that involve categorization or tagging (for example, only for a particular sport or team); Orchestration of services of different kinds in the cloud; Distributed architecture/OS-specific software builds or packaging where each builder can handle only one architecture or OS.
A headers exchange is designed for routing on multiple attributes that are more easily expressed as message headers than a routing key. Headers exchanges can be looked upon as "direct exchanges on steroids". Because they route based on header values, they can be used as direct exchanges where the routing key does not have to be a string; it could be an integer or a hash (dictionary) for example.
See the rabbitmq tutorials for examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With