public async Task StartAsync(CancellationToken cancellationToken)
        {
            try
            {
                var adapterConfig = new TransportAdapterConfig <LearningTransport, LearningTransport>("TransportAdapter.ScAdapterService");

                adapterConfig.CustomizeEndpointTransport(t =>
                {
                    //TODO: Customize the endpoint-facing side of the adapter
                    //Use exactly the same settings as in regular endpoints
                });

                adapterConfig.CustomizeServiceControlTransport(t =>
                {
                    //TODO: Customize the ServiceControl-facing side of the adapter
                    //e.g. specify the same connection string as ServiceControl uses.
                });

                adapter = TransportAdapter.Create(adapterConfig);

                await adapter.Start();
            }
            catch (Exception exception)
            {
                FailFast("Failed to start", exception);
            }
        }
Пример #2
0
        void MultipleBrokers()
        {
            #region MultiInstance

            var transportAdapterConfigOne = new TransportAdapterConfig <MyTransport, MyTransport>("One");
            transportAdapterConfigOne.CustomizeEndpointTransport(
                customization: transportExtensions =>
            {
                transportExtensions.ConnectionString(BrokerOneConnectionString);
            });
            transportAdapterConfigOne.CustomizeServiceControlTransport(
                customization: transportExtensions =>
            {
                transportExtensions.ConnectionString(ScConnectionString);
            });

            var transportAdapterConfigTwo = new TransportAdapterConfig <MyTransport, MyTransport>("Two");
            transportAdapterConfigTwo.CustomizeEndpointTransport(
                customization: transportExtensions =>
            {
                transportExtensions.ConnectionString(BrokerTwoConnectionString);
            });
            transportAdapterConfigTwo.CustomizeServiceControlTransport(
                customization: transportExtensions =>
            {
                transportExtensions.ConnectionString(ScConnectionString);
            });

            #endregion
        }
Пример #3
0
    static async Task Main()
    {
        Console.Title = "Samples.ServiceControl.SqlServerTransportAdapter.Adapter";
        #region AdapterTransport

        var transportAdapterConfig = new TransportAdapterConfig <SqlServerTransport, MsmqTransport>("ServiceControl.SqlServer.Adapter");

        #endregion

#pragma warning disable 618

        #region EndpointSideConfig

        transportAdapterConfig.CustomizeEndpointTransport(
            customization: transport =>
        {
            var connection = @"Data Source=.\SqlExpress;Initial Catalog=shipping;Integrated Security=True;Max Pool Size=100;Min Pool Size=10";
            transport.ConnectionString(connection);
        });

        #endregion

#pragma warning restore 618

        var adapter = TransportAdapter.Create(transportAdapterConfig);

        await adapter.Start()
        .ConfigureAwait(false);

        Console.WriteLine("Press <enter> to shutdown adapter.");
        Console.ReadLine();

        await adapter.Stop()
        .ConfigureAwait(false);
    }
Пример #4
0
    static async Task Main()
    {
        Console.Title = "Samples.ServiceControl.SqlServerTransportAdapter.Adapter";
        #region AdapterTransport

        var transportAdapterConfig = new TransportAdapterConfig <SqlServerTransport, SqlServerTransport>("ServiceControl.SqlServer.Adapter");
        #endregion

        #region EndpointSideConfig

        transportAdapterConfig.CustomizeEndpointTransport(
            customization: transport =>
        {
            var connection = @"Data Source=.\SqlExpress;Initial Catalog=nservicebus;Integrated Security=True;Max Pool Size=100;Min Pool Size=10";
            transport.ConnectionString(connection);
            transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);

            //Use custom schema
            transport.DefaultSchema("adapter");

            //Necessary to correctly route retried messages because
            //SQL Server transport 2.x did not include schema information in the address
            transport.UseSchemaForQueue(
                queueName: "Samples.ServiceControl.SqlServerTransportAdapter.Shipping",
                schema: "shipping");

            SqlHelper.EnsureDatabaseExists(connection);
            SqlHelper.CreateSchema(connection, "adapter");
        });

        #endregion

        #region SCSideConfig

        transportAdapterConfig.CustomizeServiceControlTransport(
            customization: transport =>
        {
            transport.ConnectionString(
                @"Data Source=.\SqlExpress;Initial Catalog=ServiceControl;Integrated Security=True;Max Pool Size=100;Min Pool Size=10");
        });

        #endregion

        #region ControlQueueOverride

        transportAdapterConfig.ServiceControlSideControlQueue = "Particular.ServiceControl.SQL";

        #endregion

        var adapter = TransportAdapter.Create(transportAdapterConfig);

        await adapter.Start()
        .ConfigureAwait(false);

        Console.WriteLine("Press <enter> to shutdown adapter.");
        Console.ReadLine();

        await adapter.Stop()
        .ConfigureAwait(false);
    }
Пример #5
0
        void AdvancedFeatures()
        {
            #region AdvancedFeatures

            var transportAdapterConfig = new TransportAdapterConfig <MyTransport, MyTransport>("TransportAdapter")
            {
                EndpointSideAuditQueue         = "audit_in",
                EndpointSideErrorQueue         = "error_in",
                ServiceControlSideControlQueue = "control_in"
            };

            transportAdapterConfig.CustomizeEndpointTransport(
                customization: transportExtensions =>
            {
                transportExtensions.ConnectionString(ConnectionString);
                transportExtensions.UseSpecificRouting();
            });

            transportAdapterConfig.CustomizeServiceControlTransport(
                customization: transportExtensions =>
            {
                transportExtensions.ConnectionString(ConnectionString);
            });

            #endregion
        }
Пример #6
0
    async Task AsyncOnStart()
    {
        try
        {
            var adapterConfig = new TransportAdapterConfig <LearningTransport, LearningTransport>("TransportAdapter.WindowsService");

            adapterConfig.CustomizeEndpointTransport(t =>
            {
                //TODO: Customize the endpoint-facing side of the adapter
                //Use exactly same settings as in regular endpoints
            });

            adapterConfig.CustomizeServiceControlTransport(t =>
            {
                //TODO: Customize the ServiceControl-facing side of the adapter
                //e.g. specify the same connection string as ServiceControl uses.
            });

            adapter = TransportAdapter.Create(adapterConfig);

            await adapter.Start().ConfigureAwait(false);
        }
        catch (Exception exception)
        {
            Exit("Failed to start", exception);
        }
    }
Пример #7
0
    static async Task Main()
    {
        Console.Title = "Samples.ServiceControl.SqsTransportAdapter.Adapter";
        #region AdapterTransport

        var transportAdapterConfig = new TransportAdapterConfig <SqsTransport, MsmqTransport>("ServiceControl.SQS.Adapter");

        #endregion

        #region EndpointSideConfig

        transportAdapterConfig.CustomizeEndpointTransport(transport =>
        {
            transport.S3("bucketname", "my/key/prefix");
        });

        #endregion

        var adapter = TransportAdapter.Create(transportAdapterConfig);

        await adapter.Start()
        .ConfigureAwait(false);

        Console.WriteLine("Press <enter> to shutdown adapter.");
        Console.ReadLine();

        await adapter.Stop()
        .ConfigureAwait(false);
    }
Пример #8
0
    static async Task Main()
    {
        Console.Title = "Samples.ServiceControl.RabbitMQAdapter.Adapter";
        #region AdapterTransport

        var transportAdapter =
            new TransportAdapterConfig <RabbitMQTransport, RabbitMQTransport>("ServiceControl.RabbitMQ.Adapter");

        transportAdapter.CustomizeServiceControlTransport(
            customization: transport =>
        {
            transport.ConnectionString("host=localhost");
            var delayedDelivery = transport.DelayedDelivery();

            transport.UseConventionalRoutingTopology();
        });

        #endregion

#pragma warning disable 618

        #region EndpointSideConfig

        transportAdapter.CustomizeEndpointTransport(
            customization: transport =>
        {
            transport.ConnectionString("host=localhost");
            var delayedDelivery = transport.DelayedDelivery();

            transport.UseDirectRoutingTopology();
        });

        #endregion

#pragma warning restore 618

        #region AdapterQueueConfiguration

        transportAdapter.EndpointSideErrorQueue   = "adapter_error";
        transportAdapter.EndpointSideAuditQueue   = "adapter_audit";
        transportAdapter.EndpointSideControlQueue = "adapter_Particular.ServiceControl";

        transportAdapter.ServiceControlSideErrorQueue   = "error";
        transportAdapter.ServiceControlSideAuditQueue   = "audit";
        transportAdapter.ServiceControlSideControlQueue = "Particular.ServiceControl";

        #endregion

        var adapter = TransportAdapter.Create(transportAdapter);

        await adapter.Start()
        .ConfigureAwait(false);

        Console.WriteLine("Press <enter> to shutdown adapter.");
        Console.ReadLine();

        await adapter.Stop()
        .ConfigureAwait(false);
    }
Пример #9
0
    static async Task AsyncMain()
    {
        #region AdapterTransport

        var transportAdapterConfig = new TransportAdapterConfig <SqlServerTransport, SqlServerTransport>("ServiceControl.SqlServer.Adapter");

        #endregion

#pragma warning disable 618

        #region EndpointSideConfig

        transportAdapterConfig.CustomizeEndpointTransport(
            customization: transport =>
        {
            transport.EnableLegacyMultiInstanceMode(Connections.GetConnection);
            //HACK: SQLServer expects this to be present. Will be solved in SQL 3.1
            var settings = transport.GetSettings();
            settings.Set <EndpointInstances>(new EndpointInstances());
        });

        #endregion

#pragma warning restore 618

        #region SCSideConfig

        transportAdapterConfig.CustomizeServiceControlTransport(
            customization: transport =>
        {
            var connection = @"Data Source=.\SqlExpress;Initial Catalog=ServiceControl;Integrated Security=True;Max Pool Size=100;Min Pool Size=10";
            transport.ConnectionString(connection);
            //HACK: SQLServer expects this to be present. Will be solved in SQL 3.1
            var settings = transport.GetSettings();
            settings.Set <EndpointInstances>(new EndpointInstances());
        });

        #endregion

        #region ControlQueueOverride

        transportAdapterConfig.ServiceControlSideControlQueue = "Particular.ServiceControl.SQL";

        #endregion

        var adapter = TransportAdapter.Create(transportAdapterConfig);

        await adapter.Start()
        .ConfigureAwait(false);

        Console.WriteLine("Press <enter> to shutdown adapter.");
        Console.ReadLine();

        await adapter.Stop()
        .ConfigureAwait(false);
    }
Пример #10
0
    static async Task Main()
    {
        Console.Title = "Samples.ServiceControl.SqlServerTransportAdapter.Adapter";
        #region AdapterTransport

        var transportAdapterConfig = new TransportAdapterConfig <SqlServerTransport, SqlServerTransport>("ServiceControl.SqlServer.Adapter");

        #endregion

#pragma warning disable 618

        #region EndpointSideConfig

        transportAdapterConfig.CustomizeEndpointTransport(
            customization: transport =>
        {
            transport.EnableLegacyMultiInstanceMode(Connections.GetConnection);

            SqlHelper.EnsureDatabaseExists(Connections.Adapter);
        });

        #endregion

#pragma warning restore 618

        #region SCSideConfig

        transportAdapterConfig.CustomizeServiceControlTransport(
            customization: transport =>
        {
            var connection = @"Data Source=.\SqlExpress;Initial Catalog=ServiceControl;Integrated Security=True;Max Pool Size=100;Min Pool Size=10";
            transport.ConnectionString(connection);
        });

        #endregion

        #region ControlQueueOverride

        transportAdapterConfig.ServiceControlSideControlQueue = "Particular.ServiceControl.SQL";

        #endregion

        var adapter = TransportAdapter.Create(transportAdapterConfig);

        await adapter.Start()
        .ConfigureAwait(false);

        Console.WriteLine("Press <enter> to shutdown adapter.");
        Console.ReadLine();

        await adapter.Stop()
        .ConfigureAwait(false);
    }
Пример #11
0
        async Task Lifecycle()
        {
            #region Lifecycle

            var config = new TransportAdapterConfig <MyTransport, MyOtherTransport>("Adapter");

            var adapter = TransportAdapter.Create(config);

            //Starting up
            await adapter.Start().ConfigureAwait(false);

            //Shutting down
            await adapter.Stop().ConfigureAwait(false);

            #endregion
        }
Пример #12
0
    static async Task AsyncMain()
    {
        #region AdapterTransport

        var transportAdapterConfig = new TransportAdapterConfig <SqlServerTransport, MsmqTransport>("ServiceControl.SqlServer.Adapter");

        #endregion

#pragma warning disable 618

        #region EndpointSideConfig

        transportAdapterConfig.CustomizeEndpointTransport(
            customization: transport =>
        {
            var connection = @"Data Source=.\SqlExpress;Initial Catalog=shipping;Integrated Security=True;Max Pool Size=100;Min Pool Size=10";
            transport.ConnectionString(connection);
            //HACK: SQLServer expects this to be present. Will be solved in SQL 3.1
            var settings = transport.GetSettings();
            settings.Set <EndpointInstances>(new EndpointInstances());
        });

        #endregion

        transportAdapterConfig.CustomizeServiceControlTransport(
            customization: transport =>
        {
            //HACK: Latest MSMQ requires this setting. To be moved to the transport adapter core.
            var settings = transport.GetSettings();
            settings.Set("errorQueue", "poison");
        });

#pragma warning restore 618

        var adapter = TransportAdapter.Create(transportAdapterConfig);

        await adapter.Start()
        .ConfigureAwait(false);

        Console.WriteLine("Press <enter> to shutdown adapter.");
        Console.ReadLine();

        await adapter.Stop()
        .ConfigureAwait(false);
    }
Пример #13
0
        public static async Task AsyncMain()
        {
            Console.Title = "Samples.ServiceControl.SqsTransportAdapter.Adapter";
            #region AdapterTransport

            var transportAdapterConfig = new TransportAdapterConfig <SqsTransport, MsmqTransport>("ServiceControl.SQS.Adapter");
            transportAdapterConfig.EndpointSideAuditQueue   = "audit";
            transportAdapterConfig.EndpointSideErrorQueue   = "error";
            transportAdapterConfig.EndpointSideControlQueue = "Particular.ServiceControl";

            #endregion

            #region EndpointSideConfig

            transportAdapterConfig.CustomizeEndpointTransport(transport =>
            {
                var s3Configuration = transport.S3("nsb-poc", "name/order");

                transport.ClientFactory(() => new AmazonSQSClient(new AmazonSQSConfig
                {
                    RegionEndpoint = RegionEndpoint.USEast1,
                }));

                s3Configuration.ClientFactory(() => new AmazonS3Client(
                                                  new AmazonS3Config
                {
                    RegionEndpoint = RegionEndpoint.USEast1
                }));
            });

            #endregion

            var adapter = TransportAdapter.TransportAdapter.Create(transportAdapterConfig);

            await adapter.Start()
            .ConfigureAwait(false);

            Console.WriteLine("Press <enter> to shutdown adapter.");
            Console.ReadLine();

            await adapter.Stop()
            .ConfigureAwait(false);
        }
Пример #14
0
        void Configuration(TransportAdapterConfig <MyTransport, MyTransport> transportAdapterConfig)
        {
            #region AuditQueues

            transportAdapterConfig.EndpointSideAuditQueue       = "audit_in";
            transportAdapterConfig.ServiceControlSideAuditQueue = "audit_out";

            #endregion

            #region ErrorQueues

            transportAdapterConfig.EndpointSideErrorQueue       = "error_in";
            transportAdapterConfig.ServiceControlSideErrorQueue = "error_out";

            #endregion

            #region ControlQueues

            transportAdapterConfig.EndpointSideControlQueue       = "control_in";
            transportAdapterConfig.ServiceControlSideControlQueue = "control_out";

            #endregion

            #region PoisonQueue

            transportAdapterConfig.PoisonMessageQueue = "poison_queue";

            #endregion

            #region ControlRetries

            transportAdapterConfig.ControlForwardingImmediateRetries = 10;

            #endregion

            #region RetryRetries

            transportAdapterConfig.RetryForwardingImmediateRetries = 10;

            #endregion
        }
Пример #15
0
        public static async Task AsyncMain()
        {
            Console.Title = "Samples.ServiceControl.SqsTransportAdapter.Adapter";

            var transportAdapterConfig =
                new TransportAdapterConfig <SqsTransport, MsmqTransport>("ServiceControl.SQS.Adapter")
            {
                EndpointSideAuditQueue   = "audit",
                EndpointSideErrorQueue   = "error",
                EndpointSideControlQueue = "Particular.ServiceControl"
            };

            transportAdapterConfig.CustomizeEndpointTransport(transport =>
            {
                var s3Configuration = transport.S3("ramon-sqs", "support/20180629");

                var region = RegionEndpoint.EUWest1;

                transport.ClientFactory(() => new AmazonSQSClient(new AmazonSQSConfig
                {
                    RegionEndpoint = region,
                }));

                s3Configuration.ClientFactory(() => new AmazonS3Client(
                                                  new AmazonS3Config
                {
                    RegionEndpoint = region
                }));
            });

            var adapter = TransportAdapter.TransportAdapter.Create(transportAdapterConfig);

            await adapter.Start()
            .ConfigureAwait(false);

            Console.WriteLine("Press <enter> to shutdown adapter.");
            Console.ReadLine();

            await adapter.Stop()
            .ConfigureAwait(false);
        }
Пример #16
0
        void MixedTransports()
        {
            #region MixedTransports

            var transportAdapterConfig =
                new TransportAdapterConfig <MyOtherTransport, MyTransport>("MyOtherTransport");

            transportAdapterConfig.CustomizeEndpointTransport(
                customization: transportExtensions =>
            {
                transportExtensions.ConnectionString(OtherTransportConnectionString);
            });

            transportAdapterConfig.CustomizeServiceControlTransport(
                customization: transportExtensions =>
            {
                transportExtensions.ConnectionString(ConnectionString);
            });

            #endregion
        }
        async Task AsyncOnStart()
        {
            const string catalogName = "ServiceControl";

            await SqlHelper.EnsureDatabaseExists(catalogName);

            var transportAdapterConfig = new TransportAdapterConfig <SqlServerTransport, SqlServerTransport>(serviceName)
            {
                EndpointSideAuditQueue       = "audit",
                EndpointSideErrorQueue       = "error",
                ServiceControlSideAuditQueue = "audit_adapted",
                ServiceControlSideErrorQueue = "error_adapted"
            };

            transportAdapterConfig.CustomizeEndpointTransport(transport => transport.ConnectionString(SqlHelper.BuildCatalogConnectionString(catalogName)));

            transportAdapterConfig.CustomizeServiceControlTransport(transport => transport.ConnectionString(SqlHelper.BuildCatalogConnectionString(catalogName)));

            transportAdapter = TransportAdapter.Create(transportAdapterConfig);

            await transportAdapter.Start().ConfigureAwait(false);
        }
Пример #18
0
        static async Task AsyncMain()
        {
            Console.Title = adapterName;

            var config = new TransportAdapterConfig <LearningTransport, MsmqTransport>(adapterName);

            config.CustomizeServiceControlTransport(
                customization: transport =>
            {
                //HACK: Latest MSMQ requires this setting. To be moved to the transport adapter core.
                transport.GetSettings().Set("errorQueue", "poison");
            });

            var adapter = TransportAdapter.Create(config);
            await adapter.Start().ConfigureAwait(false);

            Console.WriteLine();
            Console.WriteLine($"{adapterName} created and configured; press any key to stop program.");
            Console.WriteLine();
            Console.ReadKey();

            await adapter.Stop().ConfigureAwait(false);
        }
Пример #19
0
    static async Task AsyncMain()
    {
        #region AdapterTransport

        var transportAdapterConfig = new TransportAdapterConfig <SqlServerTransport, SqlServerTransport>("ServiceControl.SqlServer.Adapter");

        #endregion

        #region EndpointSideConfig

        transportAdapterConfig.CustomizeEndpointTransport(
            customization: transport =>
        {
            transport.ConnectionString(
                @"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True;Max Pool Size=100;Min Pool Size=10");

            //Use custom schema
            transport.DefaultSchema("adapter");

            //Necassary to correctly route retried messages because
            //SQL Server transport 2.x did not include schema information in the address
            transport.UseSchemaForQueue("Samples.ServiceControl.SqlServerTransportAdapter.Shipping", "shipping");

            //HACK: SQLServer expects this to be present. Will be solved in SQL 3.1
            transport.GetSettings().Set <EndpointInstances>(new EndpointInstances());
        });

        #endregion

        #region SCSideConfig

        transportAdapterConfig.CustomizeServiceControlTransport(
            customization: transport =>
        {
            transport.ConnectionString(
                @"Data Source=.\SQLEXPRESS;Initial Catalog=ServiceControl;Integrated Security=True;Max Pool Size=100;Min Pool Size=10");

            //HACK: SQLServer expects this to be present. Will be solved in SQL 3.1
            var settings = transport.GetSettings();
            settings.Set <EndpointInstances>(new EndpointInstances());
        });

        #endregion

        #region ControlQueueOverride

        transportAdapterConfig.ServiceControlSideControlQueue = "Particular.ServiceControl.SQL";

        #endregion

        var adapter = TransportAdapter.Create(transportAdapterConfig);

        await adapter.Start()
        .ConfigureAwait(false);

        Console.WriteLine("Press <enter> to shutdown adapter.");
        Console.ReadLine();

        await adapter.Stop()
        .ConfigureAwait(false);
    }
Пример #20
0
    static async Task Main()
    {
        Console.Title = "Samples.ServiceControl.ASBAdapter.Adapter";
        #region AdapterTransport

        var transportAdapterConfig = new TransportAdapterConfig <AzureServiceBusTransport, AzureServiceBusTransport>("ServiceControl.ASB.Adapter");

        #endregion

#pragma warning disable 618

        #region EndpointSideConfig

        transportAdapterConfig.CustomizeEndpointTransport(
            customization: transport =>
        {
            var salesConnectionString = Environment.GetEnvironmentVariable("AzureServiceBus.ConnectionString.1");
            if (string.IsNullOrWhiteSpace(salesConnectionString))
            {
                throw new Exception("Could not read 'AzureServiceBus.ConnectionString.1' environment variable. Check sample prerequisites.");
            }
            var shippingConnectionString = Environment.GetEnvironmentVariable("AzureServiceBus.ConnectionString.2");
            if (string.IsNullOrWhiteSpace(shippingConnectionString))
            {
                throw new Exception("Could not read 'AzureServiceBus.ConnectionString.2' environment variable. Check sample prerequisites.");
            }

            transport.UseNamespaceAliasesInsteadOfConnectionStrings();
            var namespacePartitioning = transport.NamespacePartitioning();
            namespacePartitioning.AddNamespace("sales", salesConnectionString);
            namespacePartitioning.AddNamespace("shipping", shippingConnectionString);
            namespacePartitioning.UseStrategy <RoundRobinNamespacePartitioning>();
            transport.UseForwardingTopology();
            var composition = transport.Composition();
            composition.UseStrategy <HierarchyComposition>()
            .PathGenerator(path => "scadapter/");

            WorkaroundForServializerRequiredByASB(transport);
        });

        #endregion

#pragma warning restore 618

        #region SCSideConfig

        transportAdapterConfig.CustomizeServiceControlTransport(
            customization: transport =>
        {
            var connectionString = Environment.GetEnvironmentVariable("AzureServiceBus.ConnectionString.SC");
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new Exception("Could not read 'AzureServiceBus.ConnectionString.SC' environment variable. Check sample prerequisites.");
            }
            transport.ConnectionString(connectionString);
            transport.UseEndpointOrientedTopology();

            WorkaroundForServializerRequiredByASB(transport);
        });

        #endregion

        #region UseNamespaceHeader

        transportAdapterConfig.RedirectRetriedMessages((failedQ, headers) =>
        {
            if (headers.TryGetValue(AdapterSpecificHeaders.OriginalNamespace, out var namespaceAlias))
            {
                return($"{failedQ}@{namespaceAlias}");
            }
            return(failedQ);
        });

        #endregion

        #region ControlQueueOverride

        transportAdapterConfig.ServiceControlSideControlQueue = "Particular.ServiceControl.ASB";

        #endregion

        var adapter = TransportAdapter.Create(transportAdapterConfig);

        await adapter.Start()
        .ConfigureAwait(false);

        Console.WriteLine("Press <enter> to shutdown adapter.");
        Console.ReadLine();

        await adapter.Stop()
        .ConfigureAwait(false);
    }
Пример #21
0
    static async Task Main()
    {
        Console.Title = "Samples.ServiceControl.ASQAdapter.Adapter";

        #region AdapterTransport

        var transportAdapterConfig =
            new TransportAdapterConfig <AzureStorageQueueTransport, AzureStorageQueueTransport>("ServiceControl.ASQ.Adapter");

        #endregion

        #region EndpointSideConfig

        transportAdapterConfig.CustomizeEndpointTransport(
            customization: transport =>
        {
            var connectionString = Environment.GetEnvironmentVariable("AzureStorageQueue.ConnectionString.Endpoints");
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new Exception("Could not read 'AzureStorageQueue.ConnectionString.Endpoints' environment variable. Check sample prerequisites.");
            }

            transport.ConnectionString(connectionString);
            transport.UseAccountAliasesInsteadOfConnectionStrings();
            transport.DefaultAccountAlias("storage_account");

            // Required to address https://github.com/Particular/NServiceBus.AzureStorageQueues/issues/308
            transport.AccountRouting().AddAccount("storage_account", connectionString);

            #region serializer-workaround

            var settings = transport.GetSettings();

            // Register serializer used to serialize MessageWrapper (custom MessageWrapper serializer or endpoint's serializer different than JSON)
            var serializer = Tuple.Create(new NewtonsoftSerializer() as SerializationDefinition, new SettingsHolder());
            settings.Set("MainSerializer", serializer);

            #endregion
        });

        #endregion

        #region SCSideConfig

        transportAdapterConfig.CustomizeServiceControlTransport(
            customization: transport =>
        {
            var connectionString = Environment.GetEnvironmentVariable("AzureStorageQueue.ConnectionString.SC");
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new Exception("Could not read 'AzureStorageQueue.ConnectionString.SC' environment variable. Check sample prerequisites.");
            }

            transport.ConnectionString(connectionString);

            #region serializer-workaround

            var settings = transport.GetSettings();

            // Register serializer used to serialize MessageWrapper (custom MessageWrapper serializer or endpoint's serializer different than JSON)
            var serializer = Tuple.Create(new NewtonsoftSerializer() as SerializationDefinition, new SettingsHolder());
            settings.Set("MainSerializer", serializer);

            #endregion
        });

        #endregion

        #region UseStorageAccountHeader

        transportAdapterConfig.RedirectRetriedMessages((failedQ, headers) =>
        {
            if (headers.TryGetValue(AdapterSpecificHeaders.OriginalStorageAccountAlias, out var storageAccountAlias))
            {
                return($"{failedQ}@{storageAccountAlias}");
            }
            return(failedQ);
        });

        #endregion

        #region ControlQueueOverride

        transportAdapterConfig.ServiceControlSideControlQueue = "Particular.ServiceControl.ASQ";

        #endregion

        var adapter = TransportAdapter.Create(transportAdapterConfig);

        await adapter.Start()
        .ConfigureAwait(false);

        Console.WriteLine("Press <enter> to shutdown adapter.");
        Console.ReadLine();

        await adapter.Stop()
        .ConfigureAwait(false);
    }