protected override async Task ExecuteAsync(CancellationToken token) { const string EndpointName = "endpoint name"; var endpointConfiguration = new EndpointConfiguration(EndpointName); endpointConfiguration.UniquelyIdentifyRunningInstance().UsingNames(EndpointName, Environment.MachineName); endpointConfiguration.SendFailedMessagesTo("error"); endpointConfiguration.AuditProcessedMessagesTo("audit"); endpointConfiguration.DefineCriticalErrorAction(OnCriticalError); ConventionsBuilder conventions = endpointConfiguration.Conventions(); conventions .DefiningEventsAs(_ => _.Name.EndsWith("Event")) .DefiningCommandsAs(_ => _.Name.EndsWith("Command")) .DefiningMessagesAs(_ => _.Name.EndsWith("Message")); TransportExtensions <SqlServerTransport> transport = endpointConfiguration.UseTransport <SqlServerTransport>(); NServiceBus.Transport.SQLServer.SubscriptionSettings subscriptionSettings = transport.SubscriptionSettings(); subscriptionSettings.DisableSubscriptionCache(); subscriptionSettings.SubscriptionTableName("subscriptions", "transportSchema"); transport.Routing().RouteToEndpoint( Assembly.GetAssembly(typeof(MyCommand)), EndpointName); DelayedDeliverySettings delayedDeliverySettings = transport.NativeDelayedDelivery(); delayedDeliverySettings.DisableTimeoutManagerCompatibility(); transport .Transactions(TransportTransactionMode.ReceiveOnly) .ConnectionString("Data Source=sqlserver;Initial Catalog=transport;User ID=worker;Password=password;Max Pool Size=100;") .TransactionScopeOptions(TimeSpan.FromSeconds(30), IsolationLevel.ReadCommitted) .DefaultSchema("transportSchema"); this.endpoint = await Endpoint.Start(endpointConfiguration); while (!token.IsCancellationRequested) { await Task.Delay(1000, token); } }