コード例 #1
0
        private void RunTest <TTransportInit, TMessage>(QueueConnection queueConnection,
                                                        bool addInterceptors,
                                                        long messageCount,
                                                        ILogger logProvider,
                                                        Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
                                                        Action <QueueConnection, QueueProducerConfiguration, long, string, ICreationScope> verify,
                                                        bool sendViaBatch,
                                                        string route,
                                                        ICreationScope scope, bool enableChaos)
            where TTransportInit : ITransportInit, new()
            where TMessage : class
        {
            //generate the test data
            var producer = new ProducerShared();

            producer.RunTest <TTransportInit, TMessage>(queueConnection,
                                                        addInterceptors,
                                                        messageCount,
                                                        logProvider,
                                                        g => GenerateDataWithRoute(generateData, g, route),
                                                        (a, b, c, d) => VerifyRoutes(verify, a, b, c, route, scope),
                                                        sendViaBatch,
                                                        false,
                                                        scope, enableChaos);
        }
コード例 #2
0
        public void Run(int messageCount, int timeOut, int workerCount, bool useTransactions)
        {
            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);

                        //create data
                        var producer = new ProducerShared();
                        producer.RunTest<PostgreSqlMessageQueueInit, FakeMessage>(queueName,
                            ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                            Helpers.Verify, false);

                        //process data
                        var consumer = new ConsumerPoisonMessageShared<FakeMessage>();

                        consumer.RunConsumer<PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                            false,
                            workerCount,
                            logProvider, timeOut, messageCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12));

                        ValidateErrorCounts(queueName, messageCount);
                        new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(messageCount, true, true);
                    }
                }
                finally
                {

                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<PostgreSqlMessageQueueCreation>(queueName,
                                ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }

                }
            }
        }
コード例 #3
0
        public void Run(
            int messageCount,
            bool interceptors,
            bool batchSending,
            bool enableDelay,
            bool enableExpiration,
            ConnectionInfoTypes type)
        {
            var queueName        = GenerateQueueName.Create();
            var logProvider      = LoggerShared.Create(queueName, GetType().Name);
            var producer         = new ProducerShared();
            var connectionString = new ConnectionInfo(type).ConnectionString;

            using (
                var queueCreator =
                    new QueueCreationContainer <RedisQueueInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    if (enableExpiration && enableDelay)
                    {
                        producer.RunTest <RedisQueueInit, FakeMessage>(queueName,
                                                                       connectionString, interceptors, messageCount, logProvider, Helpers.GenerateDelayExpiredData,
                                                                       Helpers.Verify, batchSending, null);
                    }
                    else if (enableDelay)
                    {
                        producer.RunTest <RedisQueueInit, FakeMessage>(queueName,
                                                                       connectionString, interceptors, messageCount, logProvider, Helpers.GenerateDelayData,
                                                                       Helpers.Verify, batchSending, null);
                    }
                    else if (enableExpiration)
                    {
                        producer.RunTest <RedisQueueInit, FakeMessage>(queueName,
                                                                       connectionString, interceptors, messageCount, logProvider, Helpers.GenerateExpiredData,
                                                                       Helpers.Verify, batchSending, null);
                    }
                    else
                    {
                        producer.RunTest <RedisQueueInit, FakeMessage>(queueName,
                                                                       connectionString, interceptors, messageCount, logProvider, Helpers.GenerateData,
                                                                       Helpers.Verify, batchSending, null);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <RedisQueueCreation>(queueName,
                                                                               connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
コード例 #4
0
        public void Run(
            int messageCount,
            bool interceptors,
            bool batchSending,
            bool enableDelay,
            bool enableExpiration,
            ConnectionInfoTypes type)
        {

            var queueName = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);
            var producer = new ProducerShared();
            var connectionString = new ConnectionInfo(type).ConnectionString;
            using (
                var queueCreator =
                    new QueueCreationContainer<RedisQueueInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    if (enableExpiration && enableDelay)
                    {
                       producer.RunTest<RedisQueueInit, FakeMessage>(queueName,
                       connectionString, interceptors, messageCount, logProvider, Helpers.GenerateDelayExpiredData,
                       Helpers.Verify, batchSending);
                    }
                    else if (enableDelay)
                    {
                       producer.RunTest<RedisQueueInit, FakeMessage>(queueName,
                       connectionString, interceptors, messageCount, logProvider, Helpers.GenerateDelayData,
                       Helpers.Verify, batchSending);
                    }
                    else if (enableExpiration)
                    {
                        producer.RunTest<RedisQueueInit, FakeMessage>(queueName,
                       connectionString, interceptors, messageCount, logProvider, Helpers.GenerateExpiredData,
                       Helpers.Verify, batchSending);
                    }
                    else
                    {
                        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();
                    }
                }
            }
        }
コード例 #5
0
        public void Run(int messageCount, int timeOut, int workerCount, int readerCount, int queueSize, bool inMemoryDb)
        {
            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 = true;
                            oCreation.Options.EnableHeartBeat = true;
                            oCreation.Options.EnableStatus = true;
                            oCreation.Options.EnableStatusTable = true;

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

                            //create data
                            var producer = new ProducerShared();
                            producer.RunTest<SqLiteMessageQueueInit, FakeMessage>(queueName,
                                connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                Helpers.Verify, false);

                            //process data
                            var consumer = new ConsumerAsyncErrorShared<FakeMessage>();
                            consumer.RunConsumer<SqLiteMessageQueueInit>(queueName,connectionInfo.ConnectionString,
                                false,
                                logProvider,
                                messageCount, workerCount, timeOut, queueSize, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35));
                            ValidateErrorCounts(queueName, connectionInfo.ConnectionString, messageCount);
                            new VerifyQueueRecordCount(queueName, connectionInfo.ConnectionString, oCreation.Options).Verify(messageCount, true, false);
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation<SqLiteMessageQueueCreation>(queueName,
                                    connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
コード例 #6
0
        public void Run(int messageCount, int timeOut, int workerCount, int readerCount, int queueSize,
                        bool useTransactions)
        {
            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);

                        //create data
                        var producer = new ProducerShared();
                        producer.RunTest <SqlServerMessageQueueInit, FakeMessage>(queueName,
                                                                                  ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                  Helpers.Verify, false, oCreation.Scope);

                        //process data
                        var consumer = new ConsumerAsyncPoisonMessageShared <FakeMessage>();
                        consumer.RunConsumer <SqlServerMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                                                         false,
                                                                         workerCount, logProvider,
                                                                         timeOut, readerCount, queueSize, messageCount,
                                                                         TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)", null);

                        ValidateErrorCounts(queueName, messageCount);
                        new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(messageCount, true, true);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <SqlServerMessageQueueCreation>(queueName,
                                                                                          ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
コード例 #7
0
        public void Run(int messageCount, int timeOut, int workerCount, 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 = true;
                            oCreation.Options.EnableHeartBeat         = true;
                            oCreation.Options.EnableStatus            = true;
                            oCreation.Options.EnableStatusTable       = true;

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

                            //create data
                            var producer = new ProducerShared();
                            producer.RunTest <SqLiteMessageQueueInit, FakeMessage>(queueName,
                                                                                   connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                   Helpers.Verify, false, oCreation.Scope, false);

                            //process data
                            var consumer = new ConsumerPoisonMessageShared <FakeMessage>();

                            consumer.RunConsumer <SqLiteMessageQueueInit>(queueName, connectionInfo.ConnectionString,
                                                                          false,
                                                                          workerCount,
                                                                          logProvider, timeOut, messageCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", null, enableChaos);

                            ValidateErrorCounts(queueName, connectionInfo.ConnectionString, messageCount);
                            new VerifyQueueRecordCount(queueName, connectionInfo.ConnectionString, oCreation.Options).Verify(messageCount, true, true);
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName,
                                                                                           connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
コード例 #8
0
        public void Run(int messageCount, int timeOut, int workerCount,
                        ConnectionInfoTypes type, bool route)
        {
            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
                {
                    //create data
                    if (route)
                    {
                        var producer = new ProducerShared();
                        producer.RunTest <RedisQueueInit, FakeMessage>(queueName,
                                                                       connectionString, false, messageCount, logProvider, Helpers.GenerateRouteData,
                                                                       Helpers.Verify, false, null, false);
                    }
                    else
                    {
                        var producer = new ProducerShared();
                        producer.RunTest <RedisQueueInit, FakeMessage>(queueName,
                                                                       connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                       Helpers.Verify, false, null, false);
                    }

                    //process data
                    var defaultRoute = route ? Helpers.DefaultRoute : null;
                    var consumer     = new ConsumerPoisonMessageShared <FakeMessage>();

                    consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false,
                                                          workerCount,
                                                          logProvider, timeOut, messageCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)", defaultRoute, false);

                    ValidateErrorCounts(queueName, connectionString, messageCount);
                    using (
                        var count = new VerifyQueueRecordCount(queueName, connectionString))
                    {
                        count.Verify(messageCount, true, 2);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <RedisQueueCreation>(queueName,
                                                                               connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
コード例 #9
0
        public void Run(int messageCount, int timeOut, int workerCount)
        {
            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);

                            //create data
                            var producer = new ProducerShared();
                            producer.RunTest <MemoryMessageQueueInit, FakeMessage>(queueName,
                                                                                   connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                   Helpers.Verify, false, oCreation.Scope, false);

                            //process data
                            var consumer = new ConsumerErrorShared <FakeMessage>();
                            consumer.RunConsumer <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString,
                                                                          false,
                                                                          logProvider,
                                                                          workerCount, timeOut, messageCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", null, false);
                            ValidateErrorCounts(oCreation.Scope, messageCount);
                            new VerifyQueueRecordCount().Verify(oCreation.Scope, messageCount, false);

                            //purge error records
                            consumer.PurgeErrorMessages <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString,
                                                                                 false, logProvider, true);

                            //memory queue doesn't actually keep errors, so nothing to check for...
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
コード例 #10
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();
                }
            }
        }
コード例 #11
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, bool enableChaos)
        {
            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         = true;
                        oCreation.Options.EnableHoldTransactionUntilMessageCommitted = false;
                        oCreation.Options.EnableStatus      = true;
                        oCreation.Options.EnableStatusTable = true;

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

                        var producer = new ProducerShared();
                        producer.RunTest <PostgreSqlMessageQueueInit, FakeMessage>(queueName,
                                                                                   ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                   Helpers.Verify, false, oCreation.Scope, false);

                        var consumer = new ConsumerCancelWorkShared <PostgreSqlMessageQueueInit, FakeMessage>();
                        consumer.RunConsumer(queueName, ConnectionInfo.ConnectionString, false, logProvider,
                                             runtime, messageCount,
                                             workerCount, timeOut, x => { }, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)", null, enableChaos);

                        new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(0, false, false);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueName,
                                                                                           ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
コード例 #12
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount)
        {
            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 ProducerShared();
                            producer.RunTest <MemoryMessageQueueInit, FakeMessage>(queueName,
                                                                                   connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                                   Helpers.Verify, false, oCreation.Scope);

                            var consumer = new ConsumerShared <FakeMessage>();
                            consumer.RunConsumer <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString,
                                                                          false,
                                                                          logProvider,
                                                                          runtime, messageCount,
                                                                          workerCount, timeOut,
                                                                          TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)");

                            new VerifyQueueRecordCount().Verify(oCreation.Scope, 0, true);
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
コード例 #13
0
 private void RunTest(string queueName, int messageCount, int queueCount, ILogProvider logProvider)
 {
     var tasks = new List<Task>(queueCount);
     for (var i = 0; i < queueCount; i++)
     {
         var producer = new ProducerShared();
         var task = new Task(() => producer.RunTest<PostgreSqlMessageQueueInit, FakeMessage>(queueName, ConnectionInfo.ConnectionString, false, messageCount,
             logProvider, Helpers.GenerateData, Helpers.NoVerification, true, false));
         tasks.Add(task); 
     }
     tasks.AsParallel().ForAll(x => x.Start());
     Task.WaitAll(tasks.ToArray());
 }
コード例 #14
0
        private void RunTest(string queueName, int messageCount, int queueCount, ILogProvider logProvider, string connectionString, ICreationScope scope, bool enableChaos)
        {
            var tasks = new List <Task>(queueCount);

            for (var i = 0; i < queueCount; i++)
            {
                var producer = new ProducerShared();
                var task     = new Task(() => producer.RunTest <SqLiteMessageQueueInit, FakeMessage>(queueName, connectionString, false, messageCount,
                                                                                                     logProvider, Helpers.GenerateData, Helpers.NoVerification, true, false, scope, enableChaos));
                tasks.Add(task);
            }
            tasks.AsParallel().ForAll(x => x.Start());
            Task.WaitAll(tasks.ToArray());
        }
コード例 #15
0
        public void Run(int messageCount, int timeOut, int workerCount, ConnectionInfoTypes type)
        {
            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
                {
                    //create data
                    var producer = new ProducerShared();
                    producer.RunTest<RedisQueueInit, FakeMessage>(queueName,
                        connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                        Helpers.Verify, false);

                    //process data
                    var consumer = new ConsumerPoisonMessageShared<FakeMessage>();

                    consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false,
                        workerCount,
                        logProvider, timeOut, messageCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12));

                    ValidateErrorCounts(queueName, connectionString, messageCount);
                    using (
                        var count = new VerifyQueueRecordCount(queueName, connectionString))
                    {
                        count.Verify(messageCount, true, 2);
                    }

                }
                finally
                {

                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<RedisQueueCreation>(queueName,
                                connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }

                }
            }
        }
コード例 #16
0
        public 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 ProducerShared();
                            producer.RunTest <MemoryMessageQueueInit, FakeMessage>(queueName,
                                                                                   connectionInfo.ConnectionString, interceptors, messageCount, logProvider,
                                                                                   Helpers.GenerateData,
                                                                                   Helpers.Verify, true, oCreation.Scope, false);
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
コード例 #17
0
        public void 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 ProducerShared();
                    producer.RunTest <TTransportInit, TMessage>(queueConnection, interceptors,
                                                                messageCount, logProvider,
                                                                generateData,
                                                                verify, sendViaBatch, oCreation.Scope, enableChaos);
                }
                finally
                {
                    oCreation?.RemoveQueue();
                    oCreation?.Dispose();
                    scope?.Dispose();
                }
            }
        }
コード例 #18
0
        private void RunTest <TTransportInit, TMessage>(QueueConnection queueConnection, int messageCount,
                                                        int queueCount, ILogger logProvider, ICreationScope scope,
                                                        bool enableChaos,
                                                        Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
                                                        Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify)
            where TTransportInit : ITransportInit, new()
            where TMessage : class
        {
            var tasks = new List <Task>(queueCount);

            for (var i = 0; i < queueCount; i++)
            {
                var producer = new ProducerShared();
                var task     = new Task(() => producer.RunTest <TTransportInit, TMessage>(queueConnection, false, messageCount,
                                                                                          logProvider, generateData, Verify, true, false, scope, enableChaos));
                tasks.Add(task);
            }
            tasks.AsParallel().ForAll(x => x.Start());
            Task.WaitAll(tasks.ToArray());
        }
コード例 #19
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, ConnectionInfoTypes type)
        {
            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
                {
                    var producer = new ProducerShared();
                    producer.RunTest <RedisQueueInit, FakeMessage>(queueName,
                                                                   connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                   Helpers.Verify, false, null, false);

                    var consumer = new ConsumerShared <FakeMessage>();
                    consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false, logProvider,
                                                          runtime, messageCount,
                                                          workerCount, timeOut, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)", false);

                    using (var count = new VerifyQueueRecordCount(queueName, connectionString))
                    {
                        count.Verify(0, false, -1);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <RedisQueueCreation>(queueName,
                                                                               connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
コード例 #20
0
        public void Run(
            int messageCount,
            bool interceptors,
            bool enableDelayedProcessing,
            bool enableHeartBeat,
            bool enableMessageExpiration,
            bool enablePriority,
            bool enableStatus,
            bool enableStatusTable,
            bool additionalColumn, 
            bool inMemoryDb)
        {
            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 ProducerShared();
                            producer.RunTest<SqLiteMessageQueueInit, FakeMessage>(queueName,
                                connectionInfo.ConnectionString, interceptors, messageCount, logProvider,
                                Helpers.GenerateData,
                                Helpers.Verify, true);
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation<SqLiteMessageQueueCreation>(queueName,
                                    connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
コード例 #21
0
        public void Run(
            int messageCount,
            bool interceptors,
            bool enableDelayedProcessing,
            bool enableHeartBeat,
            bool enableHoldTransactionUntilMessageCommitted,
            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.EnableHoldTransactionUntilMessageCommitted =
                            enableHoldTransactionUntilMessageCommitted;
                        oCreation.Options.EnablePriority    = enablePriority;
                        oCreation.Options.EnableStatus      = enableStatus;
                        oCreation.Options.EnableStatusTable = enableStatusTable;

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

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

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