public async void Run(
            int messageCount,
            bool interceptors,
            bool batchSending,
            ConnectionInfoTypes type)
        {
            var queueName        = GenerateQueueName.Create();
            var logProvider      = LoggerShared.Create(queueName, GetType().Name);
            var producer         = new ProducerAsyncShared();
            var connectionString = new ConnectionInfo(type).ConnectionString;

            using (
                var queueCreator =
                    new QueueCreationContainer <RedisQueueInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    await producer.RunTestAsync <RedisQueueInit, FakeMessage>(queueName,
                                                                              connectionString, interceptors, messageCount, logProvider, Helpers.GenerateData,
                                                                              Helpers.Verify, batchSending, null).ConfigureAwait(false);
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <RedisQueueCreation>(queueName,
                                                                               connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
        public async void Run(
           int messageCount,
           bool interceptors,
           bool batchSending,
           ConnectionInfoTypes type)
        {

            var queueName = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);
            var producer = new ProducerAsyncShared();
            var connectionString = new ConnectionInfo(type).ConnectionString;
            using (
                var queueCreator =
                    new QueueCreationContainer<RedisQueueInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    await producer.RunTest<RedisQueueInit, FakeMessage>(queueName,
                       connectionString, interceptors, messageCount, logProvider, Helpers.GenerateData,
                        Helpers.Verify, batchSending);
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<RedisQueueCreation>(queueName,
                                connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
        public async void Run(
            int messageCount,
            bool interceptors)
        {
            using (var connectionInfo = new IntegrationConnectionInfo())
            {
                var queueName   = GenerateQueueName.Create();
                var logProvider = LoggerShared.Create(queueName, GetType().Name);
                using (
                    var queueCreator =
                        new QueueCreationContainer <MemoryMessageQueueInit>(
                            serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
                {
                    try
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            var result = oCreation.CreateQueue();
                            Assert.True(result.Success, result.ErrorMessage);

                            var producer = new ProducerAsyncShared();
                            await producer.RunTestAsync <MemoryMessageQueueInit, FakeMessage>(queueName,
                                                                                              connectionInfo.ConnectionString, interceptors, messageCount, logProvider,
                                                                                              Helpers.GenerateData,
                                                                                              Helpers.Verify, true, oCreation.Scope).ConfigureAwait(false);
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
        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);
            }
        }
        public async void Run(
            int messageCount,
            bool interceptors,
            bool enableDelayedProcessing,
            bool enableHeartBeat,
            bool enableHoldTransactionUntilMessageCommited,
            bool enableMessageExpiration,
            bool enablePriority,
            bool enableStatus,
            bool enableStatusTable,
            bool additionalColumn)
        {

            var queueName = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);
            using (
                var queueCreator =
                    new QueueCreationContainer<SqlServerMessageQueueInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {

                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<SqlServerMessageQueueCreation>(queueName,
                                ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.Options.EnableDelayedProcessing = enableDelayedProcessing;
                        oCreation.Options.EnableHeartBeat = enableHeartBeat;
                        oCreation.Options.EnableMessageExpiration = enableMessageExpiration;
                        oCreation.Options.EnableHoldTransactionUntilMessageCommited =
                            enableHoldTransactionUntilMessageCommited;
                        oCreation.Options.EnablePriority = enablePriority;
                        oCreation.Options.EnableStatus = enableStatus;
                        oCreation.Options.EnableStatusTable = enableStatusTable;

                        if (additionalColumn)
                        {
                            oCreation.Options.AdditionalColumns.Add(new Column("OrderID", ColumnTypes.Int, false, null));
                        }

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

                        var producer = new ProducerAsyncShared();
                        await producer.RunTest<SqlServerMessageQueueInit, FakeMessage>(queueName,
                            ConnectionInfo.ConnectionString, interceptors, messageCount, logProvider,
                            Helpers.GenerateData,
                            Helpers.Verify, false);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<SqlServerMessageQueueCreation>(queueName,
                                ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }

                }
            }
        }
Beispiel #6
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
                        bool useTransactions, int messageType)
        {
            SchedulerContainer schedulerContainer = null;

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

            var queueName   = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);

            using (var queueCreator =
                       new QueueCreationContainer <SqlServerMessageQueueInit>(
                           serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <SqlServerMessageQueueCreation>(queueName,
                                                                                          ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.Options.EnableDelayedProcessing = true;
                        oCreation.Options.EnableHeartBeat         = !useTransactions;
                        oCreation.Options.EnableHoldTransactionUntilMessageCommitted = useTransactions;
                        oCreation.Options.EnableStatus      = !useTransactions;
                        oCreation.Options.EnableStatusTable = true;

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

                        if (messageType == 1)
                        {
                            var producer = new ProducerAsyncShared();
                            producer.RunTestAsync <SqlServerMessageQueueInit, FakeMessage>(queueName,
                                                                                           ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                           Helpers.Verify, false, oCreation.Scope).Wait(timeOut / 2 * 1000);

                            var consumer = new ConsumerAsyncShared <FakeMessage> {
                                Factory = Factory
                            };
                            consumer.RunConsumer <SqlServerMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                                                             false, logProvider,
                                                                             runtime, messageCount,
                                                                             timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)");
                        }
                        else if (messageType == 2)
                        {
                            var producer = new ProducerAsyncShared();
                            producer.RunTestAsync <SqlServerMessageQueueInit, FakeMessageA>(queueName,
                                                                                            ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                            Helpers.Verify, false, oCreation.Scope).Wait(timeOut / 2 * 1000);

                            var consumer = new ConsumerAsyncShared <FakeMessageA> {
                                Factory = Factory
                            };
                            consumer.RunConsumer <SqlServerMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                                                             false, logProvider,
                                                                             runtime, messageCount,
                                                                             timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)");
                        }
                        else if (messageType == 3)
                        {
                            var producer = new ProducerAsyncShared();
                            producer.RunTestAsync <SqlServerMessageQueueInit, FakeMessageB>(queueName,
                                                                                            ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                            Helpers.Verify, false, oCreation.Scope).Wait(timeOut / 2 * 1000);

                            var consumer = new ConsumerAsyncShared <FakeMessageB> {
                                Factory = Factory
                            };
                            consumer.RunConsumer <SqlServerMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                                                             false, logProvider,
                                                                             runtime, messageCount,
                                                                             timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%10)");
                        }

                        new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(0, false, false);
                    }
                }
                finally
                {
                    schedulerContainer?.Dispose();
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <SqlServerMessageQueueCreation>(queueName,
                                                                                          ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
        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();
                }
            }
        }
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
                        int messageType, ConnectionInfoTypes type)
        {
            SchedulerContainer schedulerContainer = null;

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

            var queueName        = GenerateQueueName.Create();
            var logProvider      = LoggerShared.Create(queueName, GetType().Name);
            var connectionString = new ConnectionInfo(type).ConnectionString;

            using (var queueCreator =
                       new QueueCreationContainer <RedisQueueInit>(
                           serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    if (messageType == 1)
                    {
                        var producer = new ProducerAsyncShared();
                        producer.RunTestAsync <RedisQueueInit, FakeMessage>(queueName,
                                                                            connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                            Helpers.Verify, false, null).Wait(timeOut * 1000 / 2);

                        var consumer = new ConsumerAsyncShared <FakeMessage> {
                            Factory = Factory
                        };
                        consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false,
                                                              logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)");
                    }
                    else if (messageType == 2)
                    {
                        var producer = new ProducerAsyncShared();
                        producer.RunTestAsync <RedisQueueInit, FakeMessageA>(queueName,
                                                                             connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                             Helpers.Verify, false, null).Wait(timeOut * 1000 / 2);

                        var consumer = new ConsumerAsyncShared <FakeMessageA> {
                            Factory = Factory
                        };
                        consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false,
                                                              logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)");
                    }
                    else if (messageType == 3)
                    {
                        var producer = new ProducerAsyncShared();
                        producer.RunTestAsync <RedisQueueInit, FakeMessageB>(queueName,
                                                                             connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                             Helpers.Verify, false, null).Wait(timeOut * 1000 / 2);


                        var consumer = new ConsumerAsyncShared <FakeMessageB> {
                            Factory = Factory
                        };
                        consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false,
                                                              logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)");
                    }

                    using (var count = new VerifyQueueRecordCount(queueName, connectionString))
                    {
                        count.Verify(0, false, -1);
                    }
                }
                finally
                {
                    schedulerContainer?.Dispose();
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <RedisQueueCreation>(queueName,
                                                                               connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
            bool useTransactions, int messageType)
        {
            SchedulerContainer schedulerContainer = null;
            if (Factory == null)
            {
                Factory = CreateFactory(workerCount, queueSize, out schedulerContainer);
            }

            var queueName = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);
            using (var queueCreator =
                new QueueCreationContainer<PostgreSqlMessageQueueInit>(
                    serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {

                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<PostgreSqlMessageQueueCreation>(queueName,
                                ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.Options.EnableDelayedProcessing = true;
                        oCreation.Options.EnableHeartBeat = !useTransactions;
                        oCreation.Options.EnableHoldTransactionUntilMessageCommited = useTransactions;
                        oCreation.Options.EnableStatus = !useTransactions;
                        oCreation.Options.EnableStatusTable = true;

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

                        if (messageType == 1)
                        {
                            var producer = new ProducerAsyncShared();
                            producer.RunTest<PostgreSqlMessageQueueInit, FakeMessage>(queueName,
                                ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                Helpers.Verify, false).Wait(timeOut / 2 * 1000);

                            var consumer = new ConsumerAsyncShared<FakeMessage> {Factory = Factory};
                            consumer.RunConsumer<PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                false, logProvider,
                                runtime, messageCount,
                                timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12));
                        }
                        else if (messageType == 2)
                        {
                            var producer = new ProducerAsyncShared();
                            producer.RunTest<PostgreSqlMessageQueueInit, FakeMessageA>(queueName,
                                ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                Helpers.Verify, false).Wait(timeOut / 2 * 1000);

                            var consumer = new ConsumerAsyncShared<FakeMessageA> {Factory = Factory};
                            consumer.RunConsumer<PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                false, logProvider,
                                runtime, messageCount,
                                timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12));
                        }
                        else if (messageType == 3)
                        {
                            var producer = new ProducerAsyncShared();
                            producer.RunTest<PostgreSqlMessageQueueInit, FakeMessageB>(queueName,
                                ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                Helpers.Verify, false).Wait(timeOut / 2 * 1000);

                            var consumer = new ConsumerAsyncShared<FakeMessageB> {Factory = Factory};
                            consumer.RunConsumer<PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                false, logProvider,
                                runtime, messageCount,
                                timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12));
                        }

                        new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(0, false, false);
                    }
                }
                finally
                {
                    schedulerContainer?.Dispose();
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<PostgreSqlMessageQueueCreation>(queueName,
                                ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
            int messageType, ConnectionInfoTypes type)
        {
            SchedulerContainer schedulerContainer = null;
            if (Factory == null)
            {
                Factory = CreateFactory(workerCount, queueSize, out schedulerContainer);
            }

            var queueName = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);
            var connectionString = new ConnectionInfo(type).ConnectionString;
            using (var queueCreator =
                new QueueCreationContainer<RedisQueueInit>(
                    serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    if (messageType == 1)
                    {
                        var producer = new ProducerAsyncShared();
                        producer.RunTest<RedisQueueInit, FakeMessage>(queueName,
                            connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                            Helpers.Verify, false).Wait(timeOut * 1000 / 2);

                        var consumer = new ConsumerAsyncShared<FakeMessage> {Factory = Factory};
                        consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false,
                            logProvider,
                            runtime, messageCount,
                            timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12));
                    }
                    else if (messageType == 2)
                    {
                        var producer = new ProducerAsyncShared();
                        producer.RunTest<RedisQueueInit, FakeMessageA>(queueName,
                            connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                            Helpers.Verify, false).Wait(timeOut * 1000 / 2);

                        var consumer = new ConsumerAsyncShared<FakeMessageA> {Factory = Factory};
                        consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false,
                            logProvider,
                            runtime, messageCount,
                            timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12));
                    }
                    else if (messageType == 3)
                    {
                        var producer = new ProducerAsyncShared();
                        producer.RunTest<RedisQueueInit, FakeMessageB>(queueName,
                            connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                            Helpers.Verify, false).Wait(timeOut * 1000 / 2);


                        var consumer = new ConsumerAsyncShared<FakeMessageB> {Factory = Factory};
                        consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false,
                            logProvider,
                            runtime, messageCount,
                            timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12));
                    }

                    using (var count = new VerifyQueueRecordCount(queueName, connectionString))
                    {
                        count.Verify(0, false, -1);
                    }
                }
                finally
                {
                    schedulerContainer?.Dispose();
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<RedisQueueCreation>(queueName,
                               connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
Beispiel #11
0
        public async void Run(
            int messageCount,
            bool interceptors,
            bool enableDelayedProcessing,
            bool enableHeartBeat,
            bool enableMessageExpiration,
            bool enablePriority,
            bool enableStatus,
            bool enableStatusTable,
            bool additionalColumn,
            bool inMemoryDb,
            bool enableChaos)
        {
            using (var connectionInfo = new IntegrationConnectionInfo(inMemoryDb))
            {
                var queueName   = GenerateQueueName.Create();
                var logProvider = LoggerShared.Create(queueName, GetType().Name);
                using (
                    var queueCreator =
                        new QueueCreationContainer <SqLiteMessageQueueInit>(
                            serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
                {
                    try
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName,
                                                                                           connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.Options.EnableDelayedProcessing = enableDelayedProcessing;
                            oCreation.Options.EnableHeartBeat         = enableHeartBeat;
                            oCreation.Options.EnableMessageExpiration = enableMessageExpiration;
                            oCreation.Options.EnablePriority          = enablePriority;
                            oCreation.Options.EnableStatus            = enableStatus;
                            oCreation.Options.EnableStatusTable       = enableStatusTable;

                            if (additionalColumn)
                            {
                                oCreation.Options.AdditionalColumns.Add(new Column("OrderID", ColumnTypes.Integer, false, null));
                            }

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

                            var producer = new ProducerAsyncShared();
                            await producer.RunTestAsync <SqLiteMessageQueueInit, FakeMessage>(queueName,
                                                                                              connectionInfo.ConnectionString, interceptors, messageCount, logProvider,
                                                                                              Helpers.GenerateData,
                                                                                              Helpers.Verify, true, oCreation.Scope, enableChaos).ConfigureAwait(false);
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName,
                                                                                           connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
                        int messageType)
        {
            SchedulerContainer schedulerContainer = null;

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


            using (var connectionInfo = new IntegrationConnectionInfo())
            {
                var queueName   = GenerateQueueName.Create();
                var logProvider = LoggerShared.Create(queueName, GetType().Name);
                using (var queueCreator =
                           new QueueCreationContainer <MemoryMessageQueueInit>(
                               serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
                {
                    try
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            var result = oCreation.CreateQueue();
                            Assert.True(result.Success, result.ErrorMessage);

                            if (messageType == 1)
                            {
                                var producer = new ProducerAsyncShared();
                                producer.RunTestAsync <MemoryMessageQueueInit, FakeMessage>(queueName,
                                                                                            connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                            Helpers.Verify, false, oCreation.Scope, false).Wait(timeOut / 2 * 1000);

                                var consumer = new ConsumerAsyncShared <FakeMessage> {
                                    Factory = Factory
                                };
                                consumer.RunConsumer <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString,
                                                                              false, logProvider,
                                                                              runtime, messageCount,
                                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", false);
                            }
                            else if (messageType == 2)
                            {
                                var producer = new ProducerAsyncShared();
                                producer.RunTestAsync <MemoryMessageQueueInit, FakeMessageA>(queueName,
                                                                                             connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                             Helpers.Verify, false, oCreation.Scope, false).Wait(timeOut / 2 * 1000);

                                var consumer = new ConsumerAsyncShared <FakeMessageA> {
                                    Factory = Factory
                                };
                                consumer.RunConsumer <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString,
                                                                              false, logProvider,
                                                                              runtime, messageCount,
                                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", false);
                            }
                            else if (messageType == 3)
                            {
                                var producer = new ProducerAsyncShared();
                                producer.RunTestAsync <MemoryMessageQueueInit, FakeMessageB>(queueName,
                                                                                             connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                             Helpers.Verify, false, oCreation.Scope, false).Wait(timeOut / 2 * 1000);

                                var consumer = new ConsumerAsyncShared <FakeMessageB> {
                                    Factory = Factory
                                };
                                consumer.RunConsumer <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString,
                                                                              false, logProvider,
                                                                              runtime, messageCount,
                                                                              timeOut, readerCount,
                                                                              TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", false);
                            }

                            new VerifyQueueRecordCount().Verify(oCreation.Scope, 0, true);
                        }
                    }
                    finally
                    {
                        schedulerContainer?.Dispose();
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }