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(); } } } }
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.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<SqlServerMessageQueueInit, FakeMessage>(queueName, ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false); //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)); ValidateErrorCounts(queueName, messageCount); new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(messageCount, true, true); } } finally { using ( var oCreation = queueCreator.GetQueueCreation<SqlServerMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run(int messageCount, int timeOut, int workerCount, int readerCount, int queueSize, 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 ConsumerAsyncPoisonMessageShared <FakeMessage>(); consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false, workerCount, logProvider, timeOut, readerCount, queueSize, 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(); } } } }
public void Run <TTransportInit, TMessage, TTransportCreate>( QueueConnection queueConnection, int messageCount, int timeOut, int workerCount, int readerCount, int queueSize, bool enableChaos, Action <TTransportCreate> setOptions, Func <QueueProducerConfiguration, AdditionalMessageData> generateData, Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify, Action <QueueConnection, IBaseTransportOptions, ICreationScope, int, bool, bool> verifyQueueCount, Action <QueueConnection, int, ICreationScope> validateErrorCounts) where TTransportInit : ITransportInit, new() where 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; //create data var producer = new ProducerShared(); producer.RunTest <TTransportInit, TMessage>(queueConnection, false, messageCount, logProvider, generateData, verify, false, oCreation.Scope, false); //process data var consumer = new ConsumerAsyncPoisonMessageShared <TMessage>(); consumer.RunConsumer <TTransportInit>(queueConnection, false, workerCount, logProvider, timeOut, readerCount, queueSize, messageCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", null, enableChaos, scope); validateErrorCounts(queueConnection, messageCount, scope); verifyQueueCount(queueConnection, oCreation.BaseTransportOptions, scope, messageCount, true, true); } finally { oCreation?.RemoveQueue(); oCreation?.Dispose(); scope?.Dispose(); } } }
public void Run(int messageCount, int timeOut, int workerCount, int readerCount, int queueSize, 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 ConsumerAsyncPoisonMessageShared<FakeMessage>(); consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false, workerCount, logProvider, timeOut, readerCount, queueSize, 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(); } } } }