public void Run <TTransportInit, TTransportCreate>(
            QueueConnection queueConnection,
            int messageCount, int queueCount, LinqMethodTypes linqMethodTypes, bool enableChaos,
            Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
            Action <QueueConnection, IBaseTransportOptions, ICreationScope, int, string> verifyQueueCount)
            where TTransportInit : ITransportInit, new()
            where TTransportCreate : class, IQueueCreation
        {
            var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name);

            using (var queueCreator =
                       new QueueCreationContainer <TTransportInit>(
                           serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                ICreationScope scope     = null;
                var            oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection);
                try
                {
                    var result = oCreation.CreateQueue();
                    Assert.True(result.Success, result.ErrorMessage);
                    scope = oCreation.Scope;

                    RunTest <TTransportInit>(queueConnection, messageCount, queueCount, logProvider, linqMethodTypes, oCreation.Scope,
                                             enableChaos, generateData);
                    LoggerShared.CheckForErrors(queueConnection.Queue);
                    verifyQueueCount(queueConnection, oCreation.BaseTransportOptions, scope, messageCount * queueCount, null);
                }
                finally
                {
                    oCreation.RemoveQueue();
                    oCreation.Dispose();
                    scope?.Dispose();
                }
            }
        }
        public void Run <TTransportInit, TTransportCreate>(
            QueueConnection queueConnection,
            int messageCount,
            LinqMethodTypes linqMethodTypes,
            bool interceptors,
            bool enableChaos,
            bool sendViaBatch,
            Action <TTransportCreate> setOptions,
            Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
            Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify)
            where TTransportInit : ITransportInit, new()
            where TTransportCreate : class, IQueueCreation
        {
            var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name);

            using (var queueCreator =
                       new QueueCreationContainer <TTransportInit>(
                           serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                ICreationScope scope     = null;
                var            oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection);
                try
                {
                    setOptions(oCreation);
                    var result = oCreation.CreateQueue();
                    Assert.True(result.Success, result.ErrorMessage);
                    scope = oCreation.Scope;

                    var id       = Guid.NewGuid();
                    var producer = new ProducerMethodShared();
                    if (linqMethodTypes == LinqMethodTypes.Compiled)
                    {
                        producer.RunTestCompiled <TTransportInit>(queueConnection, interceptors,
                                                                  messageCount, logProvider,
                                                                  generateData,
                                                                  verify, sendViaBatch, id, GenerateMethod.CreateCompiled, 0, oCreation.Scope,
                                                                  enableChaos);
                    }
                    else
                    {
                        producer.RunTestDynamic <TTransportInit>(queueConnection, interceptors, messageCount,
                                                                 logProvider,
                                                                 generateData,
                                                                 verify, sendViaBatch, id, GenerateMethod.CreateDynamic, 0, oCreation.Scope,
                                                                 enableChaos);
                    }
                }
                finally
                {
                    oCreation.RemoveQueue();
                    oCreation.Dispose();
                    scope?.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
        public void Run <TTransportInit, TMessage, TTransportCreate>(
            QueueConnection queueConnection,
            int messageCount,
            int runtime,
            int timeOut,
            int workerCount,
            bool enableChaos,
            Action <TTransportCreate> setOptions,
            Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
            Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify,
            Action <QueueConnection, IBaseTransportOptions, ICreationScope, int, bool, bool> verifyQueueCount)
            where TTransportInit : ITransportInit, new()
            where TMessage : class
            where TTransportCreate : class, IQueueCreation
        {
            var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name);

            using (
                var queueCreator =
                    new QueueCreationContainer <TTransportInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                ICreationScope scope     = null;
                var            oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection);
                try
                {
                    setOptions(oCreation);
                    var result = oCreation.CreateQueue();
                    Assert.True(result.Success, result.ErrorMessage);
                    scope = oCreation.Scope;

                    var producer = new ProducerShared();
                    producer.RunTest <TTransportInit, TMessage>(queueConnection, false, messageCount,
                                                                logProvider, generateData,
                                                                verify, false, scope, false);

                    var consumer = new ConsumerShared <TMessage>();
                    consumer.RunConsumer <TTransportInit>(queueConnection,
                                                          false,
                                                          logProvider,
                                                          runtime, messageCount,
                                                          workerCount, timeOut,
                                                          TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", enableChaos, scope);

                    verifyQueueCount(queueConnection, oCreation.BaseTransportOptions, scope, 0, false,
                                     false);
                }
                finally
                {
                    oCreation?.RemoveQueue();
                    oCreation?.Dispose();
                    scope?.Dispose();
                }
            }
        }
Ejemplo n.º 4
0
        public void Run(int messageCount, int runtime, int timeOut, int readerCount,
                        int routeCount, bool enableChaos, IntegrationConnectionInfo.ConnectionTypes connectionType)
        {
            using (var connectionInfo = new IntegrationConnectionInfo(connectionType))
            {
                var queueName = GenerateQueueName.Create();
                var consumer  = new DotNetWorkQueue.IntegrationTests.Shared.Route.Implementation.RouteMultiTests();
                consumer.Run <LiteDbMessageQueueInit, LiteDbMessageQueueCreation>(new QueueConnection(queueName,
                                                                                                      connectionInfo.ConnectionString),
                                                                                  messageCount, runtime, timeOut, readerCount, routeCount, enableChaos, x => { Helpers.SetOptions(x, false, false, true, true); },
                                                                                  Helpers.GenerateData, Helpers.Verify, Helpers.VerifyQueueCount);
            }

            using (var connectionInfo = new IntegrationConnectionInfo(connectionType))
            {
                var queueName   = GenerateQueueName.Create();
                var logProvider = LoggerShared.Create(queueName, GetType().Name);
                using (var queueCreator =
                           new QueueCreationContainer <LiteDbMessageQueueInit>(
                               serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
                {
                    var            queueConnection = new DotNetWorkQueue.Configuration.QueueConnection(queueName, connectionInfo.ConnectionString);
                    ICreationScope scope           = null;
                    var            oCreation       = queueCreator.GetQueueCreation <LiteDbMessageQueueCreation>(queueConnection);
                    try
                    {
                        oCreation.Options.EnableStatusTable = true;
                        oCreation.Options.EnableRoute       = true;

                        var result = oCreation.CreateQueue();
                        Assert.True(result.Success, result.ErrorMessage);
                        scope = oCreation.Scope;

                        var routeTest = new RouteMultiTestsShared();
                        routeTest.RunTest <LiteDbMessageQueueInit, FakeMessageA>(queueConnection,
                                                                                 true, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false,
                                                                                 GenerateRoutes(routeCount, 1), GenerateRoutes(routeCount, routeCount + 1), runtime,
                                                                                 timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), oCreation.Scope,
                                                                                 "second(*%3)", enableChaos);

                        new VerifyQueueRecordCount(queueName, connectionInfo.ConnectionString, oCreation.Options, scope)
                        .Verify(0, false, false);
                    }
                    finally
                    {
                        oCreation?.RemoveQueue();
                        oCreation?.Dispose();
                        scope?.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public void Run <TTransportInit, TJobQueueCreator, TTransportCreate>(
     QueueConnection queueConnection,
     bool interceptors,
     bool dynamic,
     Action <QueueConnection, long, ICreationScope> verify,
     Action <QueueConnection, ICreationScope> setErrorFlag)
     where TTransportInit : ITransportInit, new()
     where TJobQueueCreator : class, IJobQueueCreation
     where TTransportCreate : class, IQueueCreation
 {
     using (var trace = SharedSetup.CreateTrace("jobscheduler"))
     {
         using (var queueCreator =
                    new QueueCreationContainer <TTransportInit>((x) => x.RegisterNonScopedSingleton(trace.Source)))
         {
             var            oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection);
             ICreationScope scope     = oCreation.Scope;
             using (var queueContainer =
                        new QueueContainer <TTransportInit>(x => x.RegisterNonScopedSingleton(scope).RegisterNonScopedSingleton(trace.Source)))
             {
                 try
                 {
                     var tests = new JobSchedulerTestsShared();
                     if (!dynamic)
                     {
                         tests.RunEnqueueTestCompiled <TTransportInit, TJobQueueCreator>(
                             queueConnection, interceptors,
                             verify, setErrorFlag,
                             queueContainer.CreateTimeSync(queueConnection.Connection),
                             oCreation.Scope, LoggerShared.Create(queueConnection.Queue, GetType().Name));
                     }
                     else
                     {
                         tests.RunEnqueueTestDynamic <TTransportInit, TJobQueueCreator>(
                             queueConnection, interceptors,
                             verify, setErrorFlag,
                             queueContainer.CreateTimeSync(queueConnection.Connection),
                             oCreation.Scope, LoggerShared.Create(queueConnection.Queue, GetType().Name));
                     }
                 }
                 finally
                 {
                     oCreation.RemoveQueue();
                     oCreation.Dispose();
                     scope?.Dispose();
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
        public async Task <bool> Run <TTransportInit, TMessage, TTransportCreate>(
            QueueConnection queueConnection,
            int messageCount,
            bool interceptors,
            bool enableChaos,
            bool sendViaBatch,
            Action <TTransportCreate> setOptions,
            Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
            Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify)
            where TTransportInit : ITransportInit, new()
            where TMessage : class
            where TTransportCreate : class, IQueueCreation
        {
            var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name);

            using (
                var queueCreator =
                    new QueueCreationContainer <TTransportInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                ICreationScope scope     = null;
                var            oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection);
                try
                {
                    setOptions(oCreation);
                    var result = oCreation.CreateQueue();
                    Assert.True(result.Success, result.ErrorMessage);
                    scope = oCreation.Scope;

                    var producer = new ProducerAsyncShared();
                    await producer.RunTestAsync <TTransportInit, TMessage>(queueConnection,
                                                                           interceptors, messageCount, logProvider,
                                                                           generateData,
                                                                           verify, sendViaBatch, oCreation.Scope, enableChaos).ConfigureAwait(false);
                }
                finally
                {
                    oCreation?.RemoveQueue();
                    oCreation?.Dispose();
                    scope?.Dispose();
                }

                return(true);
            }
        }
Ejemplo n.º 7
0
        public void Run <TTransportInit, TTransportCreate>(
            QueueConnection queueConnection,
            int messageCount, int timeOut, int workerCount, LinqMethodTypes linqMethodTypes,
            bool enableChaos,
            Action <TTransportCreate> setOptions,
            Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
            Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify,
            Action <QueueConnection, IBaseTransportOptions, ICreationScope, int, bool, bool> verifyQueueCount,
            Action <QueueConnection, int, ICreationScope> validateErrorCounts)
            where TTransportInit : ITransportInit, new()
            where TTransportCreate : class, IQueueCreation
        {
            var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name);

            using (var queueCreator =
                       new QueueCreationContainer <TTransportInit>(
                           serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                ICreationScope scope     = null;
                var            oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection);
                try
                {
                    setOptions(oCreation);
                    var result = oCreation.CreateQueue();
                    Assert.True(result.Success, result.ErrorMessage);
                    scope = oCreation.Scope;

                    //create data
                    var producer = new ProducerMethodShared();
                    var id       = Guid.NewGuid();
                    if (linqMethodTypes == LinqMethodTypes.Compiled)
                    {
                        producer.RunTestCompiled <TTransportInit>(queueConnection, false, messageCount,
                                                                  logProvider, generateData,
                                                                  verify, false, id, GenerateMethod.CreateNoOpCompiled, 0, oCreation.Scope,
                                                                  false);
                    }
                    else
                    {
                        producer.RunTestDynamic <TTransportInit>(queueConnection, false, messageCount,
                                                                 logProvider, generateData,
                                                                 verify, false, id, GenerateMethod.CreateNoOpDynamic, 0, oCreation.Scope, false);
                    }

                    //process data
                    var consumer = new ConsumerMethodPoisonMessageShared();

                    consumer.RunConsumer <TTransportInit>(queueConnection,
                                                          false,
                                                          workerCount,
                                                          logProvider, timeOut, messageCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35),
                                                          "second(*%10)", enableChaos, scope);

                    validateErrorCounts(queueConnection, messageCount, scope);
                    verifyQueueCount(queueConnection, oCreation.BaseTransportOptions, scope, messageCount, true, true);
                }
                finally
                {
                    oCreation.RemoveQueue();
                    oCreation.Dispose();
                    scope?.Dispose();
                }
            }
        }
        public async Task Run <TTransportInit, TTransportCreate>(
            QueueConnection queueConnection,
            int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
            int messageType, bool enableChaos,
            Action <TTransportCreate> setOptions,
            Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
            Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify,
            Action <QueueConnection, IBaseTransportOptions, ICreationScope, int, bool, bool> verifyQueueCount)
            where TTransportInit : ITransportInit, new()
            where TTransportCreate : class, IQueueCreation
        {
            SchedulerContainer schedulerContainer = null;

            if (Factory == null)
            {
                Factory = CreateFactory(workerCount, queueSize, out schedulerContainer);
            }

            var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name);

            using (var queueCreator =
                       new QueueCreationContainer <TTransportInit>(
                           serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                ICreationScope scope     = null;
                var            oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection);
                var            time      = runtime * 1000 / 2;
                try
                {
                    setOptions(oCreation);
                    var result = oCreation.CreateQueue();
                    Assert.True(result.Success, result.ErrorMessage);
                    scope = oCreation.Scope;

                    if (messageType == 1)
                    {
                        var producer = new ProducerAsyncShared();
                        await producer.RunTestAsync <TTransportInit, FakeMessage>(queueConnection, false,
                                                                                  messageCount, logProvider, generateData,
                                                                                  verify, false, scope, false).ConfigureAwait(false);

                        Thread.Sleep(time);
                        var consumer = new ConsumerAsyncShared <FakeMessage> {
                            Factory = Factory
                        };
                        consumer.RunConsumer <TTransportInit>(queueConnection,
                                                              false, logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35),
                                                              "second(*%10)", enableChaos, scope, null);
                    }
                    else if (messageType == 2)
                    {
                        var producer = new ProducerAsyncShared();
                        await producer.RunTestAsync <TTransportInit, FakeMessageA>(queueConnection, false,
                                                                                   messageCount, logProvider, generateData,
                                                                                   verify, false, scope, false).ConfigureAwait(false);

                        Thread.Sleep(time);
                        var consumer = new ConsumerAsyncShared <FakeMessageA> {
                            Factory = Factory
                        };
                        consumer.RunConsumer <TTransportInit>(queueConnection,
                                                              false, logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35),
                                                              "second(*%10)", enableChaos, scope, null);
                    }
                    else if (messageType == 3)
                    {
                        var producer = new ProducerAsyncShared();
                        await producer.RunTestAsync <TTransportInit, FakeMessageB>(queueConnection, false,
                                                                                   messageCount, logProvider, generateData,
                                                                                   verify, false, oCreation.Scope, false).ConfigureAwait(false);

                        Thread.Sleep(time);
                        var consumer = new ConsumerAsyncShared <FakeMessageB> {
                            Factory = Factory
                        };
                        consumer.RunConsumer <TTransportInit>(queueConnection,
                                                              false, logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount,
                                                              TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", enableChaos, scope,
                                                              null);
                    }

                    verifyQueueCount(queueConnection, oCreation.BaseTransportOptions, scope, 0, false,
                                     false);
                }
                finally
                {
                    schedulerContainer?.Dispose();
                    oCreation?.RemoveQueue();
                    oCreation?.Dispose();
                    scope?.Dispose();
                }
            }
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            //we are using serilog for sample purposes
            var log = new LoggerConfiguration()
                      .WriteTo.Console()
                      .MinimumLevel.Debug()
                      .CreateLogger();

            Log.Logger = log;
            log.Information("Startup");
            log.Information(SharedConfiguration.AllSettings);

            var userSelection = -1;
            var selection     = @"
1) Direct Connection
2) Shared Connection
3) In-memory Connection
";

            while (userSelection < 0)
            {
                Console.WriteLine(selection);
                var key = Console.ReadKey(true);
                switch (key.KeyChar)
                {
                case '1':
                    userSelection = 1;
                    break;

                case '2':
                    userSelection = 2;
                    break;

                case '3':
                    userSelection = 3;
                    break;
                }
            }


            //determine our file path
            var fileLocation = Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents");
            var queueName    = ConfigurationManager.AppSettings.ReadSetting("QueueName");

            string connectionString = string.Empty;

            switch (userSelection)
            {
            case 1:
                connectionString = $"Filename={fileLocation}{ConfigurationManager.AppSettings.ReadSetting("Database")};Connection=direct;";
                break;

            case 2:
                connectionString = $"Filename={fileLocation}{ConfigurationManager.AppSettings.ReadSetting("Database")};Connection=shared;";
                break;

            case 3:
                connectionString = ":memory:";
                break;
            }

            ICreationScope scope           = null; //contains a direct or memory connection that can be passed to other instances
            var            queueConnection = new QueueConnection(queueName, connectionString);

            //create the container for creating a new queue
            using (var createQueueContainer = new QueueCreationContainer <LiteDbMessageQueueInit>(serviceRegister =>
                                                                                                  Injectors.AddInjectors(new SerilogAdapter(log), SharedConfiguration.EnableTrace,
                                                                                                                         SharedConfiguration.EnableMetrics, SharedConfiguration.EnableCompression,
                                                                                                                         SharedConfiguration.EnableEncryption, "LiteDbProducer", serviceRegister)
                                                                                                  , options => Injectors.SetOptions(options, SharedConfiguration.EnableChaos)))
            {
                using (var createQueue =
                           createQueueContainer.GetQueueCreation <LiteDbMessageQueueCreation>(queueConnection))
                {
                    scope = createQueue.Scope;
                    //Create the queue if it doesn't exist
                    if (!createQueue.QueueExists)
                    {
                        //queue options
                        createQueue.Options.EnableDelayedProcessing = true;
                        createQueue.Options.EnableMessageExpiration = true;
                        createQueue.Options.EnableStatusTable       = true;
                        var result = createQueue.CreateQueue();
                        log.Information(result.Status.ToString());
                    }
                    else
                    {
                        log.Information("Queue already exists; not creating");
                    }
                }

                //create the consumer and the producer
                using (var queueContainer = new QueueContainer <LiteDbMessageQueueInit>(
                           x => RegisterService(x, log, scope),
                           options => Injectors.SetOptions(options, SharedConfiguration.EnableChaos)))
                {
                    using (var consumeQueue = queueContainer.CreateConsumer(queueConnection))
                    {
                        //set some processing options and start looking for work
                        consumeQueue.Configuration.Worker.WorkerCount   = 4; //lets run 4 worker threads
                        consumeQueue.Configuration.HeartBeat.UpdateTime =
                            "sec(*%10)";                                     //set a heartbeat every 10 seconds
                        consumeQueue.Configuration.HeartBeat.MonitorTime =
                            TimeSpan.FromSeconds(15);                        //check for dead records every 15 seconds
                        consumeQueue.Configuration.HeartBeat.Time =
                            TimeSpan.FromSeconds(35);                        //records with no heartbeat after 35 seconds are considered dead

                        //an invalid data exception will be re-tried 3 times, with delays of 3, 6 and then finally 9 seconds
                        consumeQueue.Configuration.TransportConfiguration.RetryDelayBehavior.Add(
                            typeof(InvalidDataException),
                            new List <TimeSpan>
                        {
                            TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(9)
                        });

                        consumeQueue.Configuration.MessageExpiration.Enabled     = true;
                        consumeQueue.Configuration.MessageExpiration.MonitorTime =
                            TimeSpan.FromSeconds(20); //check for expired messages every 20 seconds
                        consumeQueue.Start <SimpleMessage>(MessageProcessing.HandleMessages);

                        using (var queue = queueContainer.CreateProducer <SimpleMessage>(queueConnection))
                        {
                            RunProducer.RunLoop(queue, ExpiredData, ExpiredDataFuture, DelayedProcessing);
                        }
                    }
                }
            }

            //dispose of direct or memory connection (if present, noop otherwise)
            scope?.Dispose();

            //if jaeger is using udp, sometimes the messages get lost; there doesn't seem to be a flush() call ?
            if (SharedConfiguration.EnableTrace)
            {
                System.Threading.Thread.Sleep(2000);
            }
        }
        public void Run <TTransportInit, TTransportCreate>(
            QueueConnection queueConnection,
            int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
            int messageType,
            LinqMethodTypes linqMethodTypes,
            bool enableChaos,
            Action <TTransportCreate> setOptions,
            Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
            Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify,
            Action <QueueConnection, IBaseTransportOptions, ICreationScope, int, bool, bool> verifyQueueCount)
            where TTransportInit : ITransportInit, new()
            where TTransportCreate : class, IQueueCreation
        {
            if (Factory == null)
            {
                Factory = CreateFactory(workerCount, queueSize);
            }

            var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name);

            using (var queueCreator =
                       new QueueCreationContainer <TTransportInit>(
                           serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                ICreationScope scope     = null;
                var            oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection);
                try
                {
                    setOptions(oCreation);
                    var result = oCreation.CreateQueue();
                    Assert.True(result.Success, result.ErrorMessage);
                    scope = oCreation.Scope;

                    if (messageType == 1)
                    {
                        var id       = Guid.NewGuid();
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTestAsync <TTransportInit>(queueConnection, false, messageCount, logProvider,
                                                               generateData,
                                                               verify, false, runtime, id, linqMethodTypes, oCreation.Scope, false).Wait(timeOut);

                        var consumer = new ConsumerMethodAsyncShared {
                            Factory = Factory
                        };
                        consumer.RunConsumer <TTransportInit>(queueConnection,
                                                              false, logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), id,
                                                              "second(*%10)", enableChaos, scope);
                    }
                    else if (messageType == 2)
                    {
                        var id       = Guid.NewGuid();
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTestAsync <TTransportInit>(queueConnection, false, messageCount, logProvider,
                                                               generateData,
                                                               verify, false, runtime, id, linqMethodTypes, oCreation.Scope, false).Wait(timeOut);

                        var consumer = new ConsumerMethodAsyncShared {
                            Factory = Factory
                        };
                        consumer.RunConsumer <TTransportInit>(queueConnection,
                                                              false, logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), id,
                                                              "second(*%10)", enableChaos, scope);
                    }
                    else if (messageType == 3)
                    {
                        var id       = Guid.NewGuid();
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTestAsync <TTransportInit>(queueConnection, false, messageCount, logProvider,
                                                               generateData,
                                                               verify, false, runtime, id, linqMethodTypes, oCreation.Scope, false).Wait(timeOut);

                        var consumer = new ConsumerMethodAsyncShared {
                            Factory = Factory
                        };
                        consumer.RunConsumer <TTransportInit>(queueConnection,
                                                              false, logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), id,
                                                              "second(*%10)", enableChaos, scope);
                    }

                    verifyQueueCount(queueConnection, oCreation.BaseTransportOptions, scope, 0, false, false);
                }
                finally
                {
                    oCreation.RemoveQueue();
                    oCreation.Dispose();
                    scope?.Dispose();
                }
            }
        }