Skip to content

Latest commit

 

History

History
58 lines (40 loc) · 2.4 KB

File metadata and controls

58 lines (40 loc) · 2.4 KB
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';

RabbitMQ tutorial - Topics

Topics

(using the AMQP 1.0 .NET client)

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.

Running

dotnet run --project ReceiveLogsTopic/ReceiveLogsTopic.csproj "kern.*"
dotnet run --project EmitLogTopic/EmitLogTopic.csproj kern.critical "A critical kernel error"

Source

Now we can move on to tutorial 6 to learn about the RPC (request/reply) pattern with RabbitMQ.