public async static Task <ConsoleHostDependencyResolver> CreateAsync()
        {
            var resolver = new ConsoleHostDependencyResolver();
            await resolver.InitializeAsync();

            return(resolver);
        }
Пример #2
0
        private static async Task RunAsync(CancellationToken token)
        {
            var configuration = DispatcherConfiguration.GetCurrentConfiguration();

            // Configure dependency resolver (including poison handler)
            var resolver = await ConsoleHostDependencyResolver.CreateAsync();

            DependencyResolverFactory.Register(
                resolver
                );

            Console.WriteLine("Initializing coordinator");

            var messageProcessor = await ProcessingCoordinator.CreateAsync(
                "Console",
                configuration.EventHubName,
                configuration.ConsumerGroupName,
                configuration.EventHubConnectionString,
                configuration.CheckpointStorageAccount,
                configuration.MaxBatchSize,
                configuration.PrefetchCount,
                configuration.ReceiveTimeout,
                configuration.MaxConcurrencyPerProcessor,
                typeof(UpdateLocationHandler).Assembly.DefinedTypes,
                (name, partitionId) =>
                new CircuitBreaker(
                    name,
                    partitionId,
                    configuration.CircuitBreakerWarningLevel,
                    configuration.CircuitBreakerTripLevel,
                    configuration.CircuitBreakerStallInterval,
                    configuration.CircuitBreakerLogCooldownInterval),
                new DispatcherInstrumentationManager(true, true).CreatePublisher("console"));

            Console.WriteLine("Running processor");

            try
            {
                await Task.Delay(Timeout.InfiniteTimeSpan, token);
            }
            catch (TaskCanceledException) { /* expected cancellation */ }

            messageProcessor.Dispose();
        }
 public async static Task<ConsoleHostDependencyResolver> CreateAsync()
 {
     var resolver = new ConsoleHostDependencyResolver();
     await resolver.InitializeAsync();
     return resolver;
 }