public NotificationsChannelTests() { var storage = new StorageFactory(); var queues = Enumerable .Range(0, 16) .Select(index => storage.CreateQueue("UseDevelopmentStorage=true", "notifications-channel-tests-" + index.ToString("D1"))) .ToArray(); m_channel = new NotificationsChannel(queues, new NotificationFormatter()); m_fixture = new Fixture().Customize(new AutoConfiguredMoqCustomization()); m_fixture.RepeatCount = 16 * 2; }
public IEventStoreConnection Build() { if (m_configuration == null) { m_configuration = new EventStoreConnectionConfiguration(); m_configure(m_configuration); m_configuration.AssertConfigurationCompleted(); m_factory = new StorageFactory(); } var connectivityState = new EventStoreConnectionState(); var journalTable = new EventJournalTable(m_factory.CreateTable( m_configuration.StorageConnectionString, m_configuration.JournalTableName)); var deploymentTable = m_factory.CreateTable( m_configuration.StorageConnectionString, m_configuration.EventStoreDeploymentTableName); var sessionFactory = new EventStreamConsumingSessionFactory( m_factory.CreateBlobContainer( m_configuration.StorageConnectionString, m_configuration.StreamConsumerSessionsBlobContainerName)); var pipelineFactory = new EventMutationPipelineFactory( m_configuration.IncomingMessageMutators, m_configuration.OutgoingMessageMutators); var queues = Enumerable .Range(0, m_configuration.NotificationQueuePartitionCount) .Select(index => m_factory.CreateQueue( m_configuration.StorageConnectionString, m_configuration.NotificationQueueName + "-" + index.ToString("D3"))) .ToArray(); var eventJournal = new EventJournal(journalTable); var consumersRegistry = new EventStreamConsumers(deploymentTable); var consumersService = new ConsumersService(consumersRegistry, eventJournal); var notificationHub = new NotificationHub( new PollingJob("NotificationHubPollingJob", new PollingTimeout()), new NotificationsChannel(queues, new NotificationFormatter()), new ReceivedNotificationProcessor()); var pendingNotificationTable = m_factory.CreateTable(m_configuration.StorageConnectionString, m_configuration.PendingNotificationsTableName); var pendingNotifications = new PendingNotifications(pendingNotificationTable); var pendingNotificationsChaserTimeout = new PollingTimeout( TimeSpan.FromMinutes(Constants.Settings.PENDING_NOTIFICATIONS_CHASER_INITIAL_TIMEOUT_IN_MINUTES), Constants.Settings.PENDING_NOTIFICATIONS_CHASER_TIMEOUT_MULTIPLIER, Constants.Settings.PENDING_NOTIFICATIONS_CHASER_TIMEOUT_INCREASING_THRESHOLD, TimeSpan.FromMinutes(Constants.Settings.PENDING_NOTIFICATIONS_CHASER_MAX_TIMEOUT_IN_MINUTES)); var pendingNotificationsChaser = new PendingNotificationsChaser( pendingNotifications, notificationHub, new PollingJob("PendingNotificationsChaserPollingJob", pendingNotificationsChaserTimeout), m_factory.CreateBlobContainer( m_configuration.StorageConnectionString, m_configuration.PendingNotificationsChaserExclusiveAccessLockBlobContainerName).CreateBlockBlob( m_configuration.PendingNotificationsChaserExclusiveAccessLockBlobName)); connectivityState.ConnectionCreated += (sender, args) => { if (m_configuration.BackgroundProcessingEnabled) { foreach (var notificationListener in m_configuration.NotificationListeners) { notificationHub.Subscribe(notificationListener); } notificationHub.StartNotificationProcessing(args.Connection); pendingNotificationsChaser.Start(); } }; connectivityState.ConnectionClosing += (sender, args) => { if (m_configuration.BackgroundProcessingEnabled) { notificationHub.StopNotificationProcessing(); pendingNotificationsChaser.Stop(); } }; connectivityState.ConnectionClosed += (sender, args) => { if (m_configuration.BackgroundProcessingEnabled) { foreach (var notificationListener in m_configuration.NotificationListeners) { notificationHub.Unsubscribe(notificationListener); } } }; return(new EventStoreConnection( connectivityState, eventJournal, notificationHub, pendingNotifications, consumersRegistry, sessionFactory, pipelineFactory, consumersService)); }
public CloudQueueAdapterTests() { Factory = new StorageFactory(); Queue = Factory.CreateQueue("UseDevelopmentStorage=true", "cloud-queue-tests-" + Guid.NewGuid().ToString("N")); }