Exemplo n.º 1
0
        public void Run(int messageCount, int runtime, int timeOut,
                        int workerCount, bool async, ConnectionInfoTypes type, LinqMethodTypes linqMethodTypes)
        {
            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 id  = Guid.NewGuid();
                    var rpc =
                        new RpcMethodShared
                        <RedisQueueInit, RedisQueueRpcConnection>();
                    rpc.Run(queueNameSend, queueNameSend, connectionString,
                            connectionString, logProviderSend, logProviderSend,
                            runtime, messageCount, workerCount, timeOut, async,
                            new RedisQueueRpcConnection(connectionString, queueNameSend), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, linqMethodTypes, "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();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Run(int messageCount, int runtime, int timeOut, 
            int workerCount, bool async, ConnectionInfoTypes type, LinqMethodTypes linqMethodTypes)
        {
            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 id = Guid.NewGuid();
                    var rpc =
                        new RpcMethodShared
                            <RedisQueueInit, FakeResponse, RedisQueueRpcConnection>();
                    rpc.Run(queueNameSend, queueNameSend, connectionString,
                        connectionString, logProviderSend, logProviderSend,
                        runtime, messageCount, workerCount, timeOut, async,
                        new RedisQueueRpcConnection(connectionString, queueNameSend), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, linqMethodTypes);

                    using (var count = new VerifyQueueRecordCount(queueNameSend, connectionString))
                    {
                        count.Verify(0, false, -1);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreatorSend.GetQueueCreation<RedisQueueCreation>(queueNameSend,
                                connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, bool async, LinqMethodTypes linqMethodTypes)
        {
            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 <SqlServerMessageQueueInit>(
                           serviceRegister => serviceRegister.Register(() => logProviderReceive, LifeStyles.Singleton)))
            {
                using (var queueCreatorSend =
                           new QueueCreationContainer <SqlServerMessageQueueInit>(
                               serviceRegister => serviceRegister.Register(() => logProviderSend, LifeStyles.Singleton)))
                {
                    try
                    {
                        using (
                            var oCreationReceive =
                                queueCreatorReceive.GetQueueCreation <SqlServerMessageQueueCreation>(queueNameReceive,
                                                                                                     ConnectionInfo.ConnectionString)
                            )
                        {
                            oCreationReceive.Options.EnableDelayedProcessing = true;
                            oCreationReceive.Options.EnableHeartBeat         = true;
                            oCreationReceive.Options.EnableHoldTransactionUntilMessageCommitted = false;
                            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 <SqlServerMessageQueueCreation>(queueNameSend,
                                                                                                      ConnectionInfo.ConnectionString)
                                )
                            {
                                oCreation.Options.EnableDelayedProcessing = true;
                                oCreation.Options.EnableHeartBeat         = true;
                                oCreation.Options.EnableHoldTransactionUntilMessageCommitted = false;
                                oCreation.Options.EnableStatus      = true;
                                oCreation.Options.EnableStatusTable = true;
                                oCreation.Options.QueueType         = QueueTypes.RpcSend;

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

                                var rpc =
                                    new RpcMethodShared
                                    <SqlServerMessageQueueInit, SqlServerRpcConnection>();

                                rpc.Run(queueNameReceive, queueNameSend, ConnectionInfo.ConnectionString,
                                        ConnectionInfo.ConnectionString, logProviderReceive, logProviderSend,
                                        runtime, messageCount, workerCount, timeOut, async,
                                        new SqlServerRpcConnection(ConnectionInfo.ConnectionString, queueNameSend,
                                                                   ConnectionInfo.ConnectionString, queueNameReceive), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, linqMethodTypes, "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 <SqlServerMessageQueueCreation>(queueNameSend,
                                                                                                  ConnectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }

                        using (
                            var oCreation =
                                queueCreatorReceive.GetQueueCreation <SqlServerMessageQueueCreation>(queueNameReceive,
                                                                                                     ConnectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, bool useTransactions, bool async, LinqMethodTypes linqMethodTypes)
        {
            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.EnableHoldTransactionUntilMessageCommited = 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.EnableHoldTransactionUntilMessageCommited = 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 id = Guid.NewGuid();

                                var rpc =
                                    new RpcMethodShared
                                        <PostgreSqlMessageQueueInit, FakeResponse, 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), id, linqMethodTypes);

                                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();
                        }
                    }
                }
            }
        }