static void Main(string[] args) { IQueueSubscriber subscriber = null; IQueueSubscriber readStorageSubscriber = null; int attempts_count = 0; while (attempts_count <= 20) { try { IContainer container = CreateContainer(); subscriber = container.Resolve <IProcessOrderQueueSubscriber>(); subscriber.Subscribe(); readStorageSubscriber = container.Resolve <IReadStorageSyncQueueSubscriber>(); readStorageSubscriber.Subscribe(); attempts_count = 21; Console.WriteLine($"### Subscription to Rabbit MQ successful"); } catch (Exception ex) { attempts_count += 1; Console.WriteLine($"### Retry connect to Rabbit MQ attempt {attempts_count}"); } Thread.Sleep(TimeSpan.FromSeconds(10)); } Console.ReadLine(); subscriber?.Dispose(); readStorageSubscriber?.Dispose(); }
static void Main(string[] args) { IContainer container = CreateContainer(); string timestampConfig = container.Resolve <IConfiguration>().GetSection("EventStoreReplica")["timestamp"]; DateTime?timestamp = null; if (!string.IsNullOrEmpty(timestampConfig)) { timestamp = DateTime.Parse(timestampConfig).ToUniversalTime(); Console.WriteLine($"### Replication start for period before {timestampConfig}"); } IEnumerable <IInitializer> initializers = container.Resolve <IEnumerable <IReplicaInitializer> >(); RunInitializers(initializers); IEnumerable <IReplicationManager> replicationManagers = container.Resolve <IEnumerable <IReplicationManager> >(); RunReplicators(replicationManagers, timestamp); IQueueSubscriber readStorageSubscriber = container.Resolve <IReadStorageSyncQueueSubscriber>(); readStorageSubscriber.Subscribe(); Console.ReadLine(); readStorageSubscriber.Dispose(); }
public async Task StartAsync(CancellationToken cancellationToken) { await DatabaseInitializer(); await _ServiceBus.Subscribe(_Subscriber, "course.queue"); }