Ejemplo n.º 1
0
 public EventProcessorFactory(
     IMessageHandler messageHandler,
     IEventProcessingExceptionHandler exceptionHandler,
     CancellationToken cancellationToken)
 {
     _messageProcessor  = new EventMessageProcessor(messageHandler);
     _exceptionHandler  = exceptionHandler ?? throw new ArgumentNullException(nameof(exceptionHandler));
     _cancellationToken = cancellationToken;
 }
Ejemplo n.º 2
0
 public EventProcessor(
     EventMessageProcessor processor,
     IEventProcessingExceptionHandler exceptionHandler,
     CancellationToken cancellationToken)
 {
     _serializer        = new EventDataSerializer();
     _processor         = processor;
     _exceptionHandler  = exceptionHandler;
     _cancellationToken = cancellationToken;
 }
Ejemplo n.º 3
0
        public static void UseEventProcessor(
            this IAppBuilder appBuilder,
            EventProcessorHost eventProcessorHost,
            IMessageHandler messageHandler,
            IEventProcessingExceptionHandler exceptionHandler)
        {
            if (appBuilder == null)
            {
                throw new ArgumentNullException(nameof(appBuilder));
            }

            if (eventProcessorHost == null)
            {
                throw new ArgumentNullException(nameof(eventProcessorHost));
            }

            var processorFactory = new EventProcessorFactory(messageHandler, exceptionHandler, CancellationToken.None);

            eventProcessorHost.RegisterEventProcessorFactoryAsync(processorFactory).Wait();

            CancellationToken appDisposing = new AppProperties(appBuilder.Properties).OnAppDisposing;

            appDisposing.Register(() => eventProcessorHost.UnregisterEventProcessorAsync().Wait());
        }