Simple SQL Server Transport Usage

Component: SQL Server Transport
NuGet Package NServiceBus.Transport.SqlServer (7-pre)
This page targets a pre-release version and is subject to change prior to the final release.


An instance of SQL Server Express installed and accessible as .\SqlExpress.

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

The database created by this sample is called SQLServerSimple.

Running the project

  1. Start both the Sender and Receiver projects.
  2. Press c to send a command, or e to publish an event to the receiver endpoint.
  3. The receiver endpoint will handle the messages in the matching handler.

Code walk-through

Configure 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