Getting Started
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Previews
Samples

Simple SQL Server transport usage

Prerequisites

An instance of SQL Server Express, accessible as .\SqlExpress.

At startup, each endpoint creates its required SQL assets, including databases, tables, and schemas.

The sample creates a database named SQLServerSimple.

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 Receiver.
  3. Receiver handles the message in the matching handler.

Code walk-through

Configuring the SQL Server transport

var connection = @"Data Source=.\SqlExpress;Database=SqlServerSimple;Integrated Security=True;Max Pool Size=100";
var routing = endpointConfiguration.UseTransport(new SqlServerTransport(connection)
{
    TransportTransactionMode = TransportTransactionMode.SendsAtomicWithReceive
});

routing.RouteToEndpoint(typeof(MyCommand), "Samples.SqlServer.SimpleReceiver");

Related Articles


Last modified