static void Main() { Console.Title = "Samples.SQLNHibernateOutboxEF.Sender"; const string letters = "ABCDEFGHIJKLMNOPQRSTUVXYZ"; var random = new Random(); var hibernateConfig = new Configuration(); hibernateConfig.DataBaseIntegration( dataBaseIntegration: configurationProperties => { configurationProperties.ConnectionStringName = "NServiceBus/Persistence"; configurationProperties.Dialect <MsSql2012Dialect>(); }); hibernateConfig.SetProperty("default_schema", "sender"); var busConfiguration = new BusConfiguration(); busConfiguration.UseSerialization <JsonSerializer>(); busConfiguration.EndpointName("Samples.SQLNHibernateOutboxEF.Sender"); #region SenderConfiguration var transport = busConfiguration.UseTransport <SqlServerTransport>(); var connectionInfo = EndpointConnectionInfo.For("Samples.SQLNHibernateOutboxEF.Receiver") .UseSchema("receiver"); transport.UseSpecificConnectionInformation(connectionInfo); transport.DefaultSchema("sender"); busConfiguration.UsePersistence <NHibernatePersistence>(); busConfiguration.EnableOutbox(); #endregion using (var bus = Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press enter to send a message"); Console.WriteLine("Press any key to exit"); while (true) { var key = Console.ReadKey(); Console.WriteLine(); if (key.Key != ConsoleKey.Enter) { return; } var orderId = new string(Enumerable.Range(0, 4).Select(x => letters[random.Next(letters.Length)]).ToArray()); var orderSubmitted = new OrderSubmitted { OrderId = orderId, Value = random.Next(100) }; bus.Publish(orderSubmitted); } } }
CompositeConnectionStringProvider ConfigureConnectionStringProvider(FeatureConfigurationContext context, LocalConnectionParams localConnectionParams) { const string transportConnectionStringPrefix = "NServiceBus/Transport/"; var configConnectionStrings = connectionStrings .Where(x => x.Name.StartsWith(transportConnectionStringPrefix)) .Select(x => { string schema; var connectionString = x.ConnectionString.ExtractSchemaName(out schema); var endpoint = x.Name.Replace(transportConnectionStringPrefix, String.Empty); return(EndpointConnectionInfo.For(endpoint).UseConnectionString(connectionString).UseSchema(schema)); }); var configProvidedPerEndpointConnectionStrings = new CollectionConnectionStringProvider(configConnectionStrings, localConnectionParams); var programmaticallyProvidedPerEndpointConnectionStrings = CreateProgrammaticPerEndpointConnectionStringProvider(context, localConnectionParams); var connectionStringProvider = new CompositeConnectionStringProvider( configProvidedPerEndpointConnectionStrings, programmaticallyProvidedPerEndpointConnectionStrings, new DefaultConnectionStringProvider(localConnectionParams) ); return(connectionStringProvider); }
public void Configure(BusConfiguration busConfiguration) { busConfiguration.UseTransport <SqlServerTransport>() .UseSpecificConnectionInformation( EndpointConnectionInfo.For("UsingDifferentConnectionStringsForEachEndpoint.Sender").UseConnectionString("ToBeOverridenViaConfig").UseSchema("ToBeOverridenViaConfig")) .ConnectionString(ReceiverConnectionStringWithSchema); }
IConnectionStringProvider CreateConfigPerEndpointConnectionStringProvider(LocalConnectionParams localConnectionParams) { const string transportConnectionStringPrefix = "NServiceBus/Transport/"; var configConnectionStrings = connectionStrings .Where(x => x.Name.StartsWith(transportConnectionStringPrefix)) .Select(x => { string schema; var connectionString = x.ConnectionString.ExtractSchemaName(out schema); var endpoint = x.Name.Replace(transportConnectionStringPrefix, String.Empty); var connectionInfo = EndpointConnectionInfo.For(endpoint).UseSchema(schema); var localConnectionStringBuilder = new DbConnectionStringBuilder { ConnectionString = localConnectionParams.ConnectionString }; var overriddenConnectionStringBuilder = new DbConnectionStringBuilder { ConnectionString = connectionString }; if (!localConnectionStringBuilder.EquivalentTo(overriddenConnectionStringBuilder)) { connectionInfo = connectionInfo.UseConnectionString(connectionString); } return(connectionInfo); }) .ToArray(); return(new CollectionConnectionStringProvider(configConnectionStrings, localConnectionParams)); }
static void Main() { using (ReceiverDataContext ctx = new ReceiverDataContext()) { ctx.Database.Initialize(true); } #region ReceiverConfiguration BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.UseTransport <SqlServerTransport>().UseSpecificConnectionInformation( EndpointConnectionInfo.For("sender") .UseConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=sender;Integrated Security=True")); busConfiguration.UsePersistence <NHibernatePersistence>().RegisterManagedSessionInTheContainer(); busConfiguration.EnableOutbox(); #endregion using (Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press <enter> to exit"); Console.ReadLine(); } }
void MultiInstance(BusConfiguration busConfiguration) { #region sqlserver-multiinstance-upgrade [2.1,3.0) var transport = busConfiguration.UseTransport <SqlServerTransport>(); // Option 1 transport .UseSpecificConnectionInformation( EndpointConnectionInfo.For("RemoteEndpoint") .UseConnectionString("SomeConnectionString"), EndpointConnectionInfo.For("AnotherEndpoint") .UseConnectionString("SomeOtherConnectionString")); // Option 2 transport .UseSpecificConnectionInformation(x => { if (x == "RemoteEndpoint") { var connectionInfo = ConnectionInfo.Create(); return(connectionInfo.UseConnectionString("SomeConnectionString")); } if (x == "AnotherEndpoint") { var connectionInfo = ConnectionInfo.Create(); return(connectionInfo.UseConnectionString("SomeOtherConnectionString")); } return(null); }); #endregion }
static void Main(string[] args) { const string letters = "ABCDEFGHIJKLMNOPQRSTUVXYZ"; var random = new Random(); var busConfig = new BusConfiguration(); #region SenderConfiguration busConfig.UseTransport <SqlServerTransport>().DefaultSchema("sender") .UseSpecificConnectionInformation(EndpointConnectionInfo.For("receiver").UseSchema("receiver")); busConfig.UsePersistence <NHibernatePersistence>(); #endregion var bus = Bus.Create(busConfig).Start(); while (true) { Console.WriteLine("Press <enter> to send a message"); Console.ReadLine(); var orderId = new String(Enumerable.Range(0, 4).Select(x => letters[random.Next(letters.Length)]).ToArray()); bus.Publish(new OrderSubmitted() { OrderId = orderId, Value = random.Next(100) }); } }
static void Main(string[] args) { #region NHibernate var hibernateConfig = new Configuration(); hibernateConfig.DataBaseIntegration(x => { x.ConnectionStringName = "NServiceBus/Persistence"; x.Dialect <MsSql2012Dialect>(); }); var mapper = new ModelMapper(); mapper.AddMapping <OrderMap>(); hibernateConfig.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); SessionFactory = hibernateConfig.BuildSessionFactory(); #endregion new SchemaExport(hibernateConfig).Execute(false, true, false); #region ReceiverConfiguration var busConfig = new BusConfiguration(); busConfig.UseTransport <SqlServerTransport>().UseSpecificConnectionInformation( EndpointConnectionInfo.For("sender") .UseConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=sender;Integrated Security=True")); busConfig.UsePersistence <NHibernatePersistence>(); busConfig.EnableOutbox(); #endregion using (Bus.Create(busConfig).Start()) { Console.WriteLine("Press <enter> to exit"); Console.ReadLine(); } }
static void Main() { Console.Title = "Samples.SQLOutboxStoreAndForward.Receiver"; BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.SQLOutboxStoreAndForward.Receiver"); #region ReceiverConfiguration busConfiguration.UseTransport <SqlServerTransport>() .UseSpecificConnectionInformation( EndpointConnectionInfo.For("Samples.SQLOutboxStoreAndForward.Sender") .UseConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=sender;Integrated Security=True")); busConfiguration.UsePersistence <NHibernatePersistence>(); busConfiguration.EnableOutbox(); #endregion busConfiguration.DisableFeature <SecondLevelRetries>(); using (Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
public void Config_file_connection_string_convention_has_precedence_over_code_configured_endpoint_connection_info() { var busConfig = new BusConfiguration(); busConfig.UseTransport <SqlServerTransport>().UseSpecificConnectionInformation( EndpointConnectionInfo.For("Endpoint1").UseConnectionString("Source=Code").UseSchema("CodeSchema"), EndpointConnectionInfo.For("Endpoint2").UseConnectionString("Source=Code").UseSchema("CodeSchema")); var connectionConfig = new ConnectionConfig(new List <ConnectionStringSettings>() { new ConnectionStringSettings("NServiceBus/Transport/Endpoint1", "Source=Config; Queue Schema=ConfigSchema") }); var builder = Activate(busConfig, connectionConfig); var connectionProvider = builder.Build <IConnectionStringProvider>(); //Config var connectionParams = connectionProvider.GetForDestination(Address.Parse("Endpoint1")); Assert.IsTrue("Source=Config".Equals(connectionParams.ConnectionString, StringComparison.InvariantCultureIgnoreCase)); Assert.AreEqual("ConfigSchema", connectionParams.Schema); //Fallback - code connectionParams = connectionProvider.GetForDestination(Address.Parse("Endpoint2")); Assert.IsTrue("Source=Code".Equals(connectionParams.ConnectionString, StringComparison.InvariantCultureIgnoreCase)); Assert.AreEqual("CodeSchema", connectionParams.Schema); }
static void Main() { Console.Title = "Samples.SqlServer.StoreAndForwardReceiver"; var busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.SqlServer.StoreAndForwardReceiver"); #region ReceiverConfiguration var transport = busConfiguration.UseTransport <SqlServerTransport>(); var receiver = @"Data Source=.\SqlExpress;Database=NsbSamplesStoreAndForwardReceiver;Integrated Security=True"; transport.ConnectionString(receiver); var sender = @"Data Source=.\SqlExpress;Database=NsbSamplesStoreAndForwardSender;Integrated Security=True"; var connectionInfo = EndpointConnectionInfo.For("Samples.SqlServer.StoreAndForwardSender") .UseConnectionString(sender); transport.UseSpecificConnectionInformation(connectionInfo); busConfiguration.UsePersistence <InMemoryPersistence>(); #endregion busConfiguration.DisableFeature <SecondLevelRetries>(); SqlHelper.EnsureDatabaseExists(receiver); using (Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
public void Configure(BusConfiguration busConfiguration) { busConfiguration.UseTransport <SqlServerTransport>() .UseSpecificConnectionInformation( EndpointConnectionInfo.For("Basic.Sender.WhenUsingDifferentConnectionStringsForEachEndpoint.SqlServerTransport").UseConnectionString("ToBeOverridenViaConfig").UseSchema("ToBeOverridenViaConfig")) .ConnectionString(ReceiverConnectionStringWithSchema); busConfiguration.Transactions().DisableDistributedTransactions(); }
public Sender() { EndpointSetup <DefaultServer>(x => x .UseTransport <SqlServerTransport>() .DefaultSchema("sender") .UseSpecificConnectionInformation( EndpointConnectionInfo.For("UsingNonStandardSchema.Receiver").UseSchema("receiver") )) .AddMapping <MyMessage>(typeof(Receiver)); }
static void Main() { const string letters = "ABCDEFGHIJKLMNOPQRSTUVXYZ"; Random random = new Random(); BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.EnableInstallers(); Configuration hibernateConfig = new Configuration(); hibernateConfig.DataBaseIntegration(x => { x.ConnectionStringName = "NServiceBus/Persistence"; x.Dialect <MsSql2012Dialect>(); }); hibernateConfig.SetProperty("default_schema", "sender"); #region SenderConfiguration busConfiguration.UseTransport <SqlServerTransport>() .DefaultSchema("sender") .UseSpecificConnectionInformation( EndpointConnectionInfo.For("receiver") .UseSchema("receiver")); busConfiguration.UsePersistence <NHibernatePersistence>() .UseConfiguration(hibernateConfig); #endregion using (IBus bus = Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press enter to send a message"); Console.WriteLine("Press any key to exit"); while (true) { ConsoleKeyInfo key = Console.ReadKey(); Console.WriteLine(); if (key.Key != ConsoleKey.Enter) { return; } string orderId = new string(Enumerable.Range(0, 4).Select(x => letters[random.Next(letters.Length)]).ToArray()); bus.Publish(new OrderSubmitted { OrderId = orderId, Value = random.Next(100) }); } } }
void OtherEndpointConnectionParamsPush(BusConfiguration busConfiguration) { #region sqlserver-singledb-multidb-push [2.1,2.0] busConfiguration.UseTransport <SqlServerTransport>() .UseSpecificConnectionInformation( EndpointConnectionInfo.For("AnotherEndpoint") .UseSchema("receiver1"), EndpointConnectionInfo.For("YetAnotherEndpoint") .UseSchema("receiver2") ); #endregion }
void RedirectAuditAndError(BusConfiguration busConfiguration) { #region sqlserver-multidb-redirect-audit-error 2.1 busConfiguration.UseTransport <SqlServerTransport>() .UseSpecificConnectionInformation( EndpointConnectionInfo.For("error") .UseConnectionString("ServiceControl connection string"), EndpointConnectionInfo.For("audit") .UseConnectionString("ServiceControl connection string") ); #endregion }
void OtherEndpointConnectionParamsPush(BusConfiguration busConfiguration) { #region sqlserver-multischema-config-push [2.1,3.0) var transport = busConfiguration.UseTransport <SqlServerTransport>(); transport.UseSpecificConnectionInformation( EndpointConnectionInfo.For("sales") .UseSchema("sender"), EndpointConnectionInfo.For("billing") .UseSchema("receiver") ); #endregion }
public void When_multi_schema_via_code_it_starts() { var context = new Context(); Scenario.Define(context) .WithEndpoint <Receiver>(b => b.CustomConfig(c => c.UseTransport <SqlServerTransport>().UseSpecificConnectionInformation( EndpointConnectionInfo.For("A").UseSchema("A"), EndpointConnectionInfo.For("B").UseSchema("B") ))) .Done(c => true) .Run(); Assert.IsNull(context.Exceptions); }
public void When_multi_db_via_code_it_fails_to_start() { var context = new Context(); Scenario.Define(context) .WithEndpoint <Receiver>(b => b.CustomConfig(c => c.UseTransport <SqlServerTransport>().UseSpecificConnectionInformation( EndpointConnectionInfo.For("A").UseConnectionString(OtherDatabaseConnectionString) ))) .AllowExceptions() .Done(c => true) .Run(); StringAssert.Contains(ExceptionText, context.Exceptions); }
void ConfigureCustomSchemaForEndpoint(BusConfiguration busConfiguration) { #region sqlserver-multischema-config-push var transport = busConfiguration.UseTransport <SqlServerTransport>(); transport.UseSpecificConnectionInformation( EndpointConnectionInfo.For("sales") .UseSchema("sender"), EndpointConnectionInfo.For("billing") .UseSchema("receiver") ); #endregion }
void ConfigureCustomSchemaForEndpointAndQueue(BusConfiguration busConfiguration) { #region sqlserver-multischema-config-for-endpoint-and-queue var transport = busConfiguration.UseTransport <SqlServerTransport>(); transport.UseSpecificConnectionInformation( EndpointConnectionInfo.For("sales") .UseSchema("sender"), EndpointConnectionInfo.For("error") .UseSchema("control") ); #endregion }
static void Main() { Console.Title = "Samples.SqlServer.StoreAndForwardSender"; var random = new Random(); var busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.SqlServer.StoreAndForwardSender"); #region SenderConfiguration var transport = busConfiguration.UseTransport <SqlServerTransport>(); var sender = @"Data Source=.\SqlExpress;Database=NsbSamplesStoreAndForwardSender;Integrated Security=True"; transport.ConnectionString(sender); var receiver = @"Data Source=.\SqlExpress;Database=NsbSamplesStoreAndForwardReceiver;Integrated Security=True"; transport.UseSpecificConnectionInformation( EndpointConnectionInfo.For("Samples.SqlServer.StoreAndForwardReceiver") .UseConnectionString(receiver) ); busConfiguration.UsePersistence <InMemoryPersistence>(); var pipeline = busConfiguration.Pipeline; pipeline.Register <ForwardBehavior.Registration>(); pipeline.Register <SendThroughLocalQueueBehavior.Registration>(); #endregion SqlHelper.EnsureDatabaseExists(sender); using (var bus = Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press enter to publish a message"); Console.WriteLine("Press any key to exit"); while (true) { var key = Console.ReadKey(); Console.WriteLine(); if (key.Key != ConsoleKey.Enter) { return; } var orderId = Guid.NewGuid(); var orderSubmitted = new OrderSubmitted { OrderId = orderId, Value = random.Next(100) }; bus.Publish(orderSubmitted); Console.WriteLine($"Order {orderId} placed"); } } }
void OtherEndpointConnectionParamsPush(BusConfiguration busConfiguration) { #region sqlserver-multidb-other-endpoint-connection-push [2.1,3.0) busConfiguration.UseTransport <SqlServerTransport>() .UseSpecificConnectionInformation( EndpointConnectionInfo.For("RemoteEndpoint") .UseSchema("schema1") .UseConnectionString("SomeConnectionString"), EndpointConnectionInfo.For("AnotherEndpoint") .UseSchema("schema2") .UseConnectionString("SomeOtherConnectionString") ); #endregion }
static void Main() { Console.Title = "Samples.SQLNHibernateOutboxEF.Receiver"; var connectionString = @"Data Source=.\SqlExpress;Database=nservicebus;Integrated Security=True"; var startupSql = File.ReadAllText("Startup.sql"); SqlHelper.ExecuteSql(connectionString, startupSql); var hibernateConfig = new Configuration(); hibernateConfig.DataBaseIntegration( dataBaseIntegration: configurationProperties => { configurationProperties.ConnectionStringName = "NServiceBus/Persistence"; configurationProperties.Dialect <MsSql2012Dialect>(); }); hibernateConfig.SetProperty("default_schema", "receiver"); var busConfiguration = new BusConfiguration(); busConfiguration.UseSerialization <JsonSerializer>(); busConfiguration.EndpointName("Samples.SQLNHibernateOutboxEF.Receiver"); #region ReceiverConfiguration var transport = busConfiguration.UseTransport <SqlServerTransport>(); var connectionInfo = EndpointConnectionInfo.For("Samples.SQLNHibernateOutboxEF.Sender") .UseSchema("sender"); transport.UseSpecificConnectionInformation(connectionInfo); transport.DefaultSchema("receiver"); var persistence = busConfiguration.UsePersistence <NHibernatePersistence>(); persistence.RegisterManagedSessionInTheContainer(); busConfiguration.EnableOutbox(); #endregion using (Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
void OtherEndpointConnectionParamsPush() { BusConfiguration busConfiguration = new BusConfiguration(); #region sqlserver-multidb-other-endpoint-connection-push 2.1 busConfiguration.UseTransport <SqlServerTransport>().UseSpecificConnectionInformation( EndpointConnectionInfo.For("RemoteEndpoint") .UseSchema("receiver1") .UseConnectionString("SomeConnectionString"), EndpointConnectionInfo.For("AnotherEndpoint") .UseSchema("receiver2") .UseConnectionString("SomeConnectionString") ); #endregion }
static void Main() { Console.Title = "Samples.SQLNHibernateOutboxEF.Receiver"; using (var receiverDataContext = new ReceiverDataContext()) { receiverDataContext.Database.Initialize(true); } var hibernateConfig = new Configuration(); hibernateConfig.DataBaseIntegration( dataBaseIntegration: configurationProperties => { configurationProperties.ConnectionStringName = "NServiceBus/Persistence"; configurationProperties.Dialect <MsSql2012Dialect>(); }); hibernateConfig.SetProperty("default_schema", "receiver"); var busConfiguration = new BusConfiguration(); busConfiguration.UseSerialization <JsonSerializer>(); busConfiguration.EndpointName("Samples.SQLNHibernateOutboxEF.Receiver"); #region ReceiverConfiguration var transport = busConfiguration.UseTransport <SqlServerTransport>(); var connectionInfo = EndpointConnectionInfo.For("Samples.SQLNHibernateOutboxEF.Sender") .UseSchema("sender"); transport.UseSpecificConnectionInformation(connectionInfo); transport.DefaultSchema("receiver"); var persistence = busConfiguration.UsePersistence <NHibernatePersistence>(); persistence.RegisterManagedSessionInTheContainer(); busConfiguration.EnableOutbox(); #endregion using (Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
static void Main() { const string letters = "ABCDEFGHIJKLMNOPQRSTUVXYZ"; Random random = new Random(); BusConfiguration busConfiguration = new BusConfiguration(); Configuration hibernateConfig = new Configuration(); hibernateConfig.DataBaseIntegration(x => { x.ConnectionStringName = "NServiceBus/Persistence"; x.Dialect <MsSql2012Dialect>(); }); hibernateConfig.SetProperty("default_schema", "dbo"); #region SenderConfiguration //sql transport is used busConfiguration.UseTransport <SqlServerTransport>() .DefaultSchema("dbo") .UseSpecificConnectionInformation( EndpointConnectionInfo.For("receiver") .UseSchema("dbo")); //data is persisted using the nhibernate busConfiguration.UsePersistence <NHibernatePersistence>() .UseConfiguration(hibernateConfig); #endregion IBus bus = Bus.Create(busConfiguration).Start(); while (true) { Console.WriteLine("Press <enter> to send a message"); Console.ReadLine(); //generate a random order id string orderId = new string(Enumerable.Range(0, 4).Select(x => letters[random.Next(letters.Length)]).ToArray()); //publish a message to receiver bus.Publish(new OrderSubmitted { OrderId = orderId, Value = random.Next(100) }); } }
public static BusConfiguration CreateSQLConfiguration(bool outbox) { BusConfiguration busConfiguration = CreateAmbientTxConfiguration(); if (outbox) { busConfiguration.EnableOutbox(); Console.WriteLine("Default Configuration overridden: Using Outbox"); } busConfiguration.UseTransport <SqlServerTransport>() .UseSpecificConnectionInformation( EndpointConnectionInfo.For("Sender") .UseConnectionString(DB_SENDER_CONNECTION)); Console.WriteLine("Default Configuration overridden: Using SQL Tranport"); return(busConfiguration); }
static void Main() { #region NHibernate Configuration hibernateConfig = new Configuration(); hibernateConfig.DataBaseIntegration(x => { x.ConnectionStringName = "NServiceBus/Persistence"; x.Dialect <MsSql2012Dialect>(); }); ModelMapper mapper = new ModelMapper(); mapper.AddMapping <OrderMap>(); hibernateConfig.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities()); #endregion new SchemaExport(hibernateConfig).Execute(false, true, false); #region ReceiverConfiguration BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.UseTransport <SqlServerTransport>() .UseSpecificConnectionInformation( EndpointConnectionInfo.For("sender") .UseConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=sender;Integrated Security=True")); busConfiguration.UsePersistence <NHibernatePersistence>() .RegisterManagedSessionInTheContainer() .UseConfiguration(hibernateConfig); busConfiguration.EnableOutbox(); #endregion busConfiguration.DisableFeature <SecondLevelRetries>(); using (Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }
public void Code_configured_connection_string_provided_as_collection_has_precedence_over_one_provided_via_transport_connection_string() { var busConfig = new BusConfiguration(); busConfig.UseTransport <SqlServerTransport>().UseSpecificConnectionInformation( EndpointConnectionInfo.For("Endpoint1").UseConnectionString("Source=Code").UseSchema("CodeSchema")); var builder = Activate(busConfig, new ConnectionConfig(new List <ConnectionStringSettings>()), "Source=Default; Queue Schema=DefaultSchema"); var connectionProvider = builder.Build <IConnectionStringProvider>(); //Code var connectionParams = connectionProvider.GetForDestination(Address.Parse("Endpoint1")); Assert.AreEqual("Source=Code", connectionParams.ConnectionString); Assert.AreEqual("CodeSchema", connectionParams.Schema); //Fallback - default connectionParams = connectionProvider.GetForDestination(Address.Parse("Endpoint2")); Assert.IsTrue("Source=Default".Equals(connectionParams.ConnectionString, StringComparison.InvariantCultureIgnoreCase)); Assert.AreEqual("DefaultSchema", connectionParams.Schema); }