Esempio n. 1
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, bool async, ConnectionInfoTypes type)
        {
            var queueNameSend    = GenerateQueueName.Create();
            var logProviderSend  = LoggerShared.Create(queueNameSend, GetType().Name);
            var connectionString = new ConnectionInfo(type).ConnectionString;

            using (var queueCreatorSend =
                       new QueueCreationContainer <RedisQueueInit>(
                           serviceRegister => serviceRegister.Register(() => logProviderSend, LifeStyles.Singleton)))
            {
                try
                {
                    var rpc =
                        new RpcShared
                        <RedisQueueInit, FakeResponse, FakeMessage, RedisQueueRpcConnection>();
                    rpc.Run(queueNameSend, queueNameSend, connectionString,
                            connectionString, logProviderSend, logProviderSend,
                            runtime, messageCount, workerCount, timeOut, async,
                            new RedisQueueRpcConnection(connectionString, queueNameSend), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)");

                    using (var count = new VerifyQueueRecordCount(queueNameSend, connectionString))
                    {
                        count.Verify(0, false, -1);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreatorSend.GetQueueCreation <RedisQueueCreation>(queueNameSend,
                                                                                   connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
Esempio n. 2
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, bool async, ConnectionInfoTypes type)
        {
            var queueNameSend = GenerateQueueName.Create();
            var logProviderSend = LoggerShared.Create(queueNameSend, GetType().Name);
            var connectionString = new ConnectionInfo(type).ConnectionString;
            using (var queueCreatorSend =
                new QueueCreationContainer<RedisQueueInit>(
                    serviceRegister => serviceRegister.Register(() => logProviderSend, LifeStyles.Singleton)))
            {
                try
                {
                    var rpc =
                        new RpcShared
                            <RedisQueueInit, FakeResponse, FakeMessage, RedisQueueRpcConnection>();
                    rpc.Run(queueNameSend, queueNameSend, connectionString,
                        connectionString, logProviderSend, logProviderSend,
                        runtime, messageCount, workerCount, timeOut, async,
                        new RedisQueueRpcConnection(connectionString, queueNameSend), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12));

                    using (var count = new VerifyQueueRecordCount(queueNameSend, connectionString))
                    {
                        count.Verify(0, false, -1);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreatorSend.GetQueueCreation<RedisQueueCreation>(queueNameSend,
                                connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
Esempio n. 3
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, bool useTransactions, bool async)
        {
            var queueNameSend      = GenerateQueueName.Create();
            var queueNameReceive   = GenerateQueueName.Create();
            var logProviderSend    = LoggerShared.Create(queueNameSend, GetType().Name);
            var logProviderReceive = LoggerShared.Create(queueNameReceive, GetType().Name);

            using (var queueCreatorReceive =
                       new QueueCreationContainer <PostgreSqlMessageQueueInit>(
                           serviceRegister => serviceRegister.Register(() => logProviderReceive, LifeStyles.Singleton)))
            {
                using (var queueCreatorSend =
                           new QueueCreationContainer <PostgreSqlMessageQueueInit>(
                               serviceRegister => serviceRegister.Register(() => logProviderSend, LifeStyles.Singleton)))
                {
                    try
                    {
                        using (
                            var oCreationReceive =
                                queueCreatorReceive.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueNameReceive,
                                                                                                      ConnectionInfo.ConnectionString)
                            )
                        {
                            oCreationReceive.Options.EnableDelayedProcessing = true;
                            oCreationReceive.Options.EnableHeartBeat         = !useTransactions;
                            oCreationReceive.Options.EnableHoldTransactionUntilMessageCommitted = useTransactions;
                            oCreationReceive.Options.EnableStatus      = !useTransactions;
                            oCreationReceive.Options.EnableStatusTable = true;
                            oCreationReceive.Options.QueueType         = QueueTypes.RpcReceive;

                            var resultReceive = oCreationReceive.CreateQueue();
                            Assert.True(resultReceive.Success, resultReceive.ErrorMessage);

                            using (
                                var oCreation =
                                    queueCreatorSend.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueNameSend,
                                                                                                       ConnectionInfo.ConnectionString)
                                )
                            {
                                oCreation.Options.EnableDelayedProcessing = true;
                                oCreation.Options.EnableHeartBeat         = !useTransactions;
                                oCreation.Options.EnableHoldTransactionUntilMessageCommitted = useTransactions;
                                oCreation.Options.EnableStatus      = !useTransactions;
                                oCreation.Options.EnableStatusTable = true;
                                oCreation.Options.QueueType         = QueueTypes.RpcSend;

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

                                var rpc =
                                    new RpcShared
                                    <PostgreSqlMessageQueueInit, FakeResponse, FakeMessage, PostgreSqlRpcConnection>();

                                rpc.Run(queueNameReceive, queueNameSend, ConnectionInfo.ConnectionString,
                                        ConnectionInfo.ConnectionString, logProviderReceive, logProviderSend,
                                        runtime, messageCount, workerCount, timeOut, async,
                                        new PostgreSqlRpcConnection(ConnectionInfo.ConnectionString, queueNameSend,
                                                                    ConnectionInfo.ConnectionString, queueNameReceive), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)");

                                new VerifyQueueRecordCount(queueNameSend, oCreation.Options).Verify(0, false, false);
                                new VerifyQueueRecordCount(queueNameReceive, oCreationReceive.Options).Verify(0, false,
                                                                                                              false);
                            }
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreatorSend.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueNameSend,
                                                                                                   ConnectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }

                        using (
                            var oCreation =
                                queueCreatorReceive.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueNameReceive,
                                                                                                      ConnectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, bool async, bool inMemoryDb)
        {
            var queueNameSend      = GenerateQueueName.Create();
            var queueNameReceive   = GenerateQueueName.Create();
            var logProviderSend    = LoggerShared.Create(queueNameSend, GetType().Name);
            var logProviderReceive = LoggerShared.Create(queueNameReceive, GetType().Name);

            using (var connectionInfo = new IntegrationConnectionInfo(inMemoryDb))
            {
                using (var queueCreatorReceive =
                           new QueueCreationContainer <SqLiteMessageQueueInit>(
                               serviceRegister => serviceRegister.Register(() => logProviderReceive, LifeStyles.Singleton)))
                {
                    using (var queueCreatorSend =
                               new QueueCreationContainer <SqLiteMessageQueueInit>(
                                   serviceRegister => serviceRegister.Register(() => logProviderSend, LifeStyles.Singleton)))
                    {
                        try
                        {
                            using (
                                var oCreationReceive =
                                    queueCreatorReceive.GetQueueCreation <SqLiteMessageQueueCreation>(queueNameReceive,
                                                                                                      connectionInfo.ConnectionString)
                                )
                            {
                                oCreationReceive.Options.EnableDelayedProcessing = true;
                                oCreationReceive.Options.EnableHeartBeat         = true;
                                oCreationReceive.Options.EnableStatus            = true;
                                oCreationReceive.Options.EnableStatusTable       = true;
                                oCreationReceive.Options.QueueType = QueueTypes.RpcReceive;

                                var resultReceive = oCreationReceive.CreateQueue();
                                Assert.True(resultReceive.Success, resultReceive.ErrorMessage);

                                using (
                                    var oCreation =
                                        queueCreatorSend.GetQueueCreation <SqLiteMessageQueueCreation>(queueNameSend,
                                                                                                       connectionInfo.ConnectionString)
                                    )
                                {
                                    oCreation.Options.EnableDelayedProcessing = true;
                                    oCreation.Options.EnableHeartBeat         = true;
                                    oCreation.Options.EnableStatus            = true;
                                    oCreation.Options.EnableStatusTable       = true;
                                    oCreation.Options.QueueType = QueueTypes.RpcSend;

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

                                    var rpc =
                                        new RpcShared
                                        <SqLiteMessageQueueInit, FakeResponse, FakeMessage, SqLiteRpcConnection>();

                                    rpc.Run(queueNameReceive, queueNameSend, connectionInfo.ConnectionString,
                                            connectionInfo.ConnectionString, logProviderReceive, logProviderSend,
                                            runtime, messageCount, workerCount, timeOut, async,
                                            new SqLiteRpcConnection(connectionInfo.ConnectionString, queueNameSend,
                                                                    connectionInfo.ConnectionString, queueNameReceive, new DbDataSource()),
                                            TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)");

                                    new VerifyQueueRecordCount(queueNameSend, connectionInfo.ConnectionString, oCreation.Options).Verify(0, false, false);
                                    new VerifyQueueRecordCount(queueNameReceive, connectionInfo.ConnectionString, oCreationReceive.Options).Verify(0, false,
                                                                                                                                                   false);
                                }
                            }
                        }
                        finally
                        {
                            using (
                                var oCreation =
                                    queueCreatorSend.GetQueueCreation <SqLiteMessageQueueCreation>(queueNameSend,
                                                                                                   connectionInfo.ConnectionString)
                                )
                            {
                                oCreation.RemoveQueue();
                            }

                            using (
                                var oCreation =
                                    queueCreatorReceive.GetQueueCreation <SqLiteMessageQueueCreation>(queueNameReceive,
                                                                                                      connectionInfo.ConnectionString)
                                )
                            {
                                oCreation.RemoveQueue();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, bool async, bool inMemoryDb)
        {
            var queueNameSend = GenerateQueueName.Create();
            var queueNameReceive = GenerateQueueName.Create();
            var logProviderSend = LoggerShared.Create(queueNameSend, GetType().Name);
            var logProviderReceive = LoggerShared.Create(queueNameReceive, GetType().Name);

            using (var connectionInfo = new IntegrationConnectionInfo(inMemoryDb))
            {
                using (var queueCreatorReceive =
                new QueueCreationContainer<SqLiteMessageQueueInit>(
                    serviceRegister => serviceRegister.Register(() => logProviderReceive, LifeStyles.Singleton)))
                {
                    using (var queueCreatorSend =
                        new QueueCreationContainer<SqLiteMessageQueueInit>(
                            serviceRegister => serviceRegister.Register(() => logProviderSend, LifeStyles.Singleton)))
                    {
                        try
                        {

                            using (
                                var oCreationReceive =
                                    queueCreatorReceive.GetQueueCreation<SqLiteMessageQueueCreation>(queueNameReceive,
                                        connectionInfo.ConnectionString)
                                )
                            {

                                oCreationReceive.Options.EnableDelayedProcessing = true;
                                oCreationReceive.Options.EnableHeartBeat = true;
                                oCreationReceive.Options.EnableStatus = true;
                                oCreationReceive.Options.EnableStatusTable = true;
                                oCreationReceive.Options.QueueType = QueueTypes.RpcReceive;

                                var resultReceive = oCreationReceive.CreateQueue();
                                Assert.True(resultReceive.Success, resultReceive.ErrorMessage);

                                using (
                                    var oCreation =
                                        queueCreatorSend.GetQueueCreation<SqLiteMessageQueueCreation>(queueNameSend,
                                            connectionInfo.ConnectionString)
                                    )
                                {
                                    oCreation.Options.EnableDelayedProcessing = true;
                                    oCreation.Options.EnableHeartBeat = true;
                                    oCreation.Options.EnableStatus = true;
                                    oCreation.Options.EnableStatusTable = true;
                                    oCreation.Options.QueueType = QueueTypes.RpcSend;

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

                                    var rpc =
                                        new RpcShared
                                            <SqLiteMessageQueueInit, FakeResponse, FakeMessage, SqLiteRpcConnection>();

                                    rpc.Run(queueNameReceive, queueNameSend, connectionInfo.ConnectionString,
                                        connectionInfo.ConnectionString, logProviderReceive, logProviderSend,
                                        runtime, messageCount, workerCount, timeOut, async,
                                        new SqLiteRpcConnection(connectionInfo.ConnectionString, queueNameSend,
                                            connectionInfo.ConnectionString, queueNameReceive),
                                        TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35));

                                    new VerifyQueueRecordCount(queueNameSend, connectionInfo.ConnectionString, oCreation.Options).Verify(0, false, false);
                                    new VerifyQueueRecordCount(queueNameReceive, connectionInfo.ConnectionString, oCreationReceive.Options).Verify(0, false,
                                        false);
                                }
                            }
                        }
                        finally
                        {
                            using (
                                var oCreation =
                                    queueCreatorSend.GetQueueCreation<SqLiteMessageQueueCreation>(queueNameSend,
                                        connectionInfo.ConnectionString)
                                )
                            {
                                oCreation.RemoveQueue();
                            }

                            using (
                                var oCreation =
                                    queueCreatorReceive.GetQueueCreation<SqLiteMessageQueueCreation>(queueNameReceive,
                                        connectionInfo.ConnectionString)
                                )
                            {
                                oCreation.RemoveQueue();
                            }
                        }
                    }
                }
            }
        }