Simple RabbitMQ Transport usage

Component: RabbitMQ Transport
NuGet NServiceBus.RabbitMQ (3.x)
Target NServiceBus Version: 5.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. The application sends an empty message to itself, via the RabbitMQ broker, and writes to the console when the message is received.

Configuration

var busConfiguration = new BusConfiguration();
busConfiguration.EndpointName("Samples.RabbitMQ.Simple");
var transport = busConfiguration.UseTransport<RabbitMQTransport>();
transport.ConnectionString("host=localhost");

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

Related Articles


Last modified