Topic exchange định tuyến message dùng wildcard pattern: * khớp đúng một từ, # khớp không hoặc nhiều từ.
Ví dụ: pattern "user." khớp "user.created" và "user.deleted" nhưng không khớp "user.profile.updated"; trong khi "user.#" khớp cả ba. Topic exchange hoàn hảo cho hệ thống event phân cấp — subscribe "orders.#" để nhận mọi order event, hoặc "orders.payment." chỉ cho payment events. Tính linh hoạt này cho phép consumer subscribe có chọn lọc mà không cần tạo queue riêng cho từng loại.
A topic exchange uses wildcard pattern matching: * matches exactly one word, # matches zero or more.
- Pattern "user.*" matches "user.created" and "user.deleted" but not "user.profile.updated", while "user.#" matches all three.
- Topic exchanges are perfect for hierarchical event systems — subscribe to "orders.#" for all order events, or "orders.payment.*" for payment-specific ones.