Simple RabbitMQ Transport Usage

Component: RabbitMQ Transport
NuGet Package NServiceBus.RabbitMQ (7-pre)
This page targets a pre-release version. Pre-releases are subject to change and samples are not guaranteed to be fully functional.


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 either sends a command or publishes an event to a receiver endpoint, via the RabbitMQ broker, and writes to the console when the message is received.


var endpointConfiguration = new EndpointConfiguration("Samples.RabbitMQ.SimpleSender");
var transport = new RabbitMQTransport(Topology.Conventional, "host=localhost");
var routing = endpointConfiguration.UseTransport(transport);

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

Related Articles

Last modified