Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Simple PostgreSQL transport usage

NuGet Package: NServiceBus.Transport.PostgreSql (8.x)
Target Version: NServiceBus 9.x

Prerequisites

The uses a database nservicebus. Ensure it exists before running the sample.

Running the sample

  1. Start both the Sender and Receiver projects.
  2. Press c to send a command, or e to publish an event, from Sender to the Receiver.
  3. The Receiver handles the message.

Code walk-through

Configuring the PostgreSQL transport

var connectionString = "User ID=user;Password=admin;Host=localhost;Port=54320;Database=nservicebus;Pooling=true;Connection Lifetime=0;Include Error Detail=true";
var routing = endpointConfiguration.UseTransport(new PostgreSqlTransport(connectionString)
{
    TransportTransactionMode = TransportTransactionMode.SendsAtomicWithReceive
});

routing.RouteToEndpoint(typeof(MyCommand), "PostgreSql.SimpleReceiver");

Related Articles