public async void Run( int messageCount, bool interceptors, bool batchSending, ConnectionInfoTypes type) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); var producer = new ProducerAsyncShared(); var connectionString = new ConnectionInfo(type).ConnectionString; using ( var queueCreator = new QueueCreationContainer<RedisQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { await producer.RunTest<RedisQueueInit, FakeMessage>(queueName, connectionString, interceptors, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, batchSending); } finally { using ( var oCreation = queueCreator.GetQueueCreation<RedisQueueCreation>(queueName, connectionString) ) { oCreation.RemoveQueue(); } } } }
public async void Run( int messageCount, bool interceptors, bool enableDelayedProcessing, bool enableHeartBeat, bool enableHoldTransactionUntilMessageCommited, bool enableMessageExpiration, bool enablePriority, bool enableStatus, bool enableStatusTable, bool additionalColumn) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using ( var queueCreator = new QueueCreationContainer<SqlServerMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation<SqlServerMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.Options.EnableDelayedProcessing = enableDelayedProcessing; oCreation.Options.EnableHeartBeat = enableHeartBeat; oCreation.Options.EnableMessageExpiration = enableMessageExpiration; oCreation.Options.EnableHoldTransactionUntilMessageCommited = enableHoldTransactionUntilMessageCommited; oCreation.Options.EnablePriority = enablePriority; oCreation.Options.EnableStatus = enableStatus; oCreation.Options.EnableStatusTable = enableStatusTable; if (additionalColumn) { oCreation.Options.AdditionalColumns.Add(new Column("OrderID", ColumnTypes.Int, false, null)); } var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); var producer = new ProducerAsyncShared(); await producer.RunTest<SqlServerMessageQueueInit, FakeMessage>(queueName, ConnectionInfo.ConnectionString, interceptors, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false); } } finally { using ( var oCreation = queueCreator.GetQueueCreation<SqlServerMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize, bool useTransactions, int messageType) { SchedulerContainer schedulerContainer = null; if (Factory == null) { Factory = CreateFactory(workerCount, queueSize, out schedulerContainer); } var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer<PostgreSqlMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation<PostgreSqlMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.Options.EnableDelayedProcessing = true; oCreation.Options.EnableHeartBeat = !useTransactions; oCreation.Options.EnableHoldTransactionUntilMessageCommited = useTransactions; oCreation.Options.EnableStatus = !useTransactions; oCreation.Options.EnableStatusTable = true; var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); if (messageType == 1) { var producer = new ProducerAsyncShared(); producer.RunTest<PostgreSqlMessageQueueInit, FakeMessage>(queueName, ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false).Wait(timeOut / 2 * 1000); var consumer = new ConsumerAsyncShared<FakeMessage> {Factory = Factory}; consumer.RunConsumer<PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString, false, logProvider, runtime, messageCount, timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12)); } else if (messageType == 2) { var producer = new ProducerAsyncShared(); producer.RunTest<PostgreSqlMessageQueueInit, FakeMessageA>(queueName, ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false).Wait(timeOut / 2 * 1000); var consumer = new ConsumerAsyncShared<FakeMessageA> {Factory = Factory}; consumer.RunConsumer<PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString, false, logProvider, runtime, messageCount, timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12)); } else if (messageType == 3) { var producer = new ProducerAsyncShared(); producer.RunTest<PostgreSqlMessageQueueInit, FakeMessageB>(queueName, ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false).Wait(timeOut / 2 * 1000); var consumer = new ConsumerAsyncShared<FakeMessageB> {Factory = Factory}; consumer.RunConsumer<PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString, false, logProvider, runtime, messageCount, timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12)); } new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(0, false, false); } } finally { schedulerContainer?.Dispose(); using ( var oCreation = queueCreator.GetQueueCreation<PostgreSqlMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize, int messageType, ConnectionInfoTypes type) { SchedulerContainer schedulerContainer = null; if (Factory == null) { Factory = CreateFactory(workerCount, queueSize, out schedulerContainer); } var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); var connectionString = new ConnectionInfo(type).ConnectionString; using (var queueCreator = new QueueCreationContainer<RedisQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { if (messageType == 1) { var producer = new ProducerAsyncShared(); producer.RunTest<RedisQueueInit, FakeMessage>(queueName, connectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false).Wait(timeOut * 1000 / 2); var consumer = new ConsumerAsyncShared<FakeMessage> {Factory = Factory}; consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false, logProvider, runtime, messageCount, timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12)); } else if (messageType == 2) { var producer = new ProducerAsyncShared(); producer.RunTest<RedisQueueInit, FakeMessageA>(queueName, connectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false).Wait(timeOut * 1000 / 2); var consumer = new ConsumerAsyncShared<FakeMessageA> {Factory = Factory}; consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false, logProvider, runtime, messageCount, timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12)); } else if (messageType == 3) { var producer = new ProducerAsyncShared(); producer.RunTest<RedisQueueInit, FakeMessageB>(queueName, connectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false).Wait(timeOut * 1000 / 2); var consumer = new ConsumerAsyncShared<FakeMessageB> {Factory = Factory}; consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false, logProvider, runtime, messageCount, timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12)); } using (var count = new VerifyQueueRecordCount(queueName, connectionString)) { count.Verify(0, false, -1); } } finally { schedulerContainer?.Dispose(); using ( var oCreation = queueCreator.GetQueueCreation<RedisQueueCreation>(queueName, connectionString) ) { oCreation.RemoveQueue(); } } } }