-
Notifications
You must be signed in to change notification settings - Fork 0
Default Exchange
Antoine Théate edited this page Jun 5, 2025
·
4 revisions
The default exchange is a direct exchange that has several special properties:
- It always exists (is pre-declared)
- Its name for AMQP 0-9-1 clients is an empty string ("")
- When a queue is declared, RabbitMQ will automatically bind that queue to the default exchange using its (queue) name as the routing key
This provides AMQP 0-9-1 applications with a mechanism that makes it convenient to publish "directly" to a queue using only its name, even though there's still a direct exchange involved under the hood.
var messageClientService = serviceProvider.GetRequiredService<IMessageClientBaseService>();
var exchangeConfiguration = new DefaultExchangeConfiguration("DefaultChannel");
var messageObservable = await messageClientService.ListenAsync<string>("Primary", exchangeConfiguration);
messageObservable.Subscribe(message => Console.WriteLine(message));var messageClientService = serviceProvider.GetRequiredService<IMessageClientBaseService>();
var exchangeConfiguration = new DefaultExchangeConfiguration("DefaultChannel");
await messageClientService.PushAsync("Primary", "A message to be sent", exchangeConfiguration);Results:
When the Micro Service B pushes the message, a new line will be written in the Console of Micro Service A with the content as "A message to be sent"
copyright @ Starion Group S.A.