Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Simple RabbitMQ Transport Usage

NuGet Package: NServiceBus.RabbitMQ (8.x)
Target Version: NServiceBus 8.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 either sends a command or publishes an event to a receiver endpoint, using the RabbitMQ broker, and 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
    An overview of the RabbitMQ transport, learn how to configure and use RabbitMQ as a transport in NServiceBus.