For the complete documentation index, see llms.txt. This section of documentation is indexed by https://docs.particular.net/samples/llms.txt. Here is the markdown version of this page. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md.

Simple RabbitMQ Transport Usage

NuGet Package:
NServiceBus.RabbitMQ 11.x
Target Version:
NServiceBus 10.x

Prerequisites

Ensure an instance of RabbitMQ is running and accessible.

Code walk-through

This sample shows basic usage of RabbitMQ as a transport for NServiceBus to connect two endpoints. The sender sends a command or publishes an event to a receiver endpoint using the RabbitMQ broker. The receiver writes to the console when the message is received.

Configuration

var endpointConfiguration = new EndpointConfiguration("Samples.RabbitMQ.SimpleSender");
var transport = endpointConfiguration.UseTransport<RabbitMQTransport>();
transport.UseConventionalRoutingTopology(QueueType.Quorum);
transport.ConnectionString("host=localhost");

The username and password can be configured in the connection string. If these are not present, the connection string defaults to host=localhost;username=guest;password=guest.

Related Articles

  • Connection settings
    The various ways to customize the RabbitMQ transport.
  • RabbitMQ Transport
    Integrate NServiceBus with RabbitMQ transport for scalable messaging and reliable distributed communication.