What are RabbitMQ exchanges?

Answer

An exchange in RabbitMQ is the component that receives messages from producers and routes them to one or more queues based on routing rules. Producers never send directly to a queue — they send to an exchange with a routing key. Four exchange types: Direct: routes messages to queues whose binding key exactly matches the routing key. Used for one-to-one routing. Fanout: routes to all bound queues, ignoring routing keys. Used for broadcast/publish-subscribe. Topic: routes based on pattern matching with wildcards (* matches one word, # matches zero or more). Flexible for hierarchical routing. Headers: routes based on message header attributes instead of routing keys — allows complex multi-attribute matching. Default (nameless) exchange: built-in direct exchange — routes to a queue with the same name as the routing key. Exchanges are declared by producers or operators before use.