Integration / RabbitMQ Interview Questions
What is the difference between direct and topic exchange?
Both direct and topic exchanges route using the message's routing key, but they differ in how strict that matching is.
| Direct Exchange | Topic Exchange |
| Requires an exact string match between routing key and binding key. | Matches routing key against a dot-separated pattern using * and #. |
| Good for simple point-to-point style routing, e.g. by task type. | Good for hierarchical routing, e.g. logs. |
| Example binding key: 'payment.processed'. | Example binding pattern: 'payment.#' matches payment.processed, payment.failed.us, etc. |
A useful mental model: a direct exchange is a topic exchange with no wildcards allowed.
Which exchange type supports wildcards like * and # in binding keys?
A direct exchange requires the routing key to:
More Related questions...