| title | RabbitMQ tutorial - Topics (AMQP 1.0) |
|---|
import TutorialsHelp from '@site/src/components/Tutorials/TutorialsHelp.md'; import T5DiagramToC from '@site/src/components/Tutorials/T5DiagramToC.md'; import T5DiagramTopicX from '@site/src/components/Tutorials/T5DiagramTopicX.md';
In the previous tutorial we used a direct exchange to route by a single criterion (severity). Topic exchanges route by patterns in the routing key — useful when messages carry multiple dimensions (for example kern.critical).
The sample declares exchange logs_topic with type topic. The publisher sets the routing key on PublisherBuilder().Exchange(exchangeName).Key(routingKey). The consumer passes one or more binding keys (patterns) on the command line and binds the temporary queue for each.
Topic binding rules:
*substitutes exactly one word.#substitutes zero or more words.- Words are separated by
.in routing keys.
dotnet run --project ReceiveLogsTopic/ReceiveLogsTopic.csproj "kern.*"
dotnet run --project EmitLogTopic/EmitLogTopic.csproj kern.critical "A critical kernel error"Now we can move on to tutorial 6 to learn about the RPC (request/reply) pattern with RabbitMQ.