public RealSimulator(string address, string connectionString) { this.address = address; var localConnectionParams = new LocalConnectionParams(null, connectionString, "dbo"); new SqlServerQueueCreator(new DefaultConnectionStringProvider(localConnectionParams), ConnectionFactory.Default()).CreateQueueIfNecessary(Address.Parse(address), null); var transportNotifications = new TransportNotifications(); taskStarted = transportNotifications.ReceiveTaskStarted.Subscribe(x => AddMessage("Thread started")); taskEnded = transportNotifications.ReceiveTaskStopped.Subscribe(x => AddMessage("Thread died")); var purgeExpiredMessagesParams = new PurgeExpiredMessagesParams { PurgeTaskDelay = Timeout.InfiniteTimeSpan, PurgeBatchSize = 1 }; dequeueStrategy = new SqlServerPollingDequeueStrategy(localConnectionParams, new ReceiveStrategyFactory(new DummyConnectionStore(), localConnectionParams, Address.Parse("error"), ConnectionFactory.Default()), new QueuePurger(new SecondaryReceiveConfiguration(_ => SecondaryReceiveSettings.Disabled()), localConnectionParams, ConnectionFactory.Default()), new SecondaryReceiveConfiguration(_ => SecondaryReceiveSettings.Disabled()), transportNotifications, new RepeatedFailuresOverTimeCircuitBreaker("A", TimeSpan.FromDays(1000), _ => { }), ConnectionFactory.Default(), purgeExpiredMessagesParams); dequeueStrategy.Init(Address.Parse(address), new TransactionSettings(true, TimeSpan.FromMinutes(2), System.Transactions.IsolationLevel.ReadCommitted, 1, false, false), ProcessMessage, (message, exception) => { }); sender = new SqlServerMessageSender(new DefaultConnectionStringProvider(localConnectionParams), new DummyConnectionStore(), new DummyCallbackAddressStore(), ConnectionFactory.Default()); }
public override void Configure(FeatureConfigurationContext context, string connectionStringWithSchema) { bool purgeOnStartup; if (context.Settings.TryGet("Transport.PurgeOnStartup", out purgeOnStartup) && purgeOnStartup) { context.Container.ConfigureComponent <QueuePurger>(DependencyLifecycle.SingleInstance); } else { context.Container.ConfigureComponent <NullQueuePurger>(DependencyLifecycle.SingleInstance); } var purgeParams = new PurgeExpiredMessagesParams { PurgeTaskDelay = context.Settings.Get <TimeSpan>(PurgeTaskDelayKey), PurgeBatchSize = context.Settings.Get <int>(PurgeBatchSizeKey) }; context.Container.ConfigureComponent(() => purgeParams, DependencyLifecycle.SingleInstance); }