Ejemplo n.º 1
0
        public async Task Start()
        {
            _eventProcessorHost = new EventProcessorHost(
                _settings.EntityPath,
                PartitionReceiver.DefaultConsumerGroupName,
                _settings.ConnectionString,
                string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", _settings.StorageAccountName, _settings.StorageAccountKey),
                _settings.StorageContainerName);

            EventProcessorFactory <T> eventProcessorFactory = new EventProcessorFactory <T>();

            await _eventProcessorHost.RegisterEventProcessorFactoryAsync(eventProcessorFactory);

            eventProcessorFactory.Processor.OnEventClose += (context, reason) => {
                OnEventClose?.Invoke(context, reason);
            };

            eventProcessorFactory.Processor.OnEventOpen += (context) => {
                OnEventOpen?.Invoke(context);
            };

            eventProcessorFactory.Processor.OnEventError += (context, error) => {
                OnEventError?.Invoke(context, error);
            };

            eventProcessorFactory.Processor.OnProcessEvents += (context, eventMessages) => {
                OnProcessEvents?.Invoke(context, eventMessages);
            };
        }
Ejemplo n.º 2
0
 public Task CloseAsync(PartitionContext context, CloseReason reason)
 {
     OnEventClose?.Invoke(context, reason);
     return(Task.CompletedTask);
 }