예제 #1
0
        async Task IEventDataReceiver.Handle(Microsoft.Azure.EventHubs.EventData message, Action <ReceiveContext> contextCallback)
        {
            var context = new EventDataReceiveContext(message, _receiveEndpointContext);

            contextCallback?.Invoke(context);

            try
            {
                await _receiveEndpointContext.ReceiveObservers.PreReceive(context).ConfigureAwait(false);

                await _receiveEndpointContext.ReceivePipe.Send(context).ConfigureAwait(false);

                await context.ReceiveCompleted.ConfigureAwait(false);

                await _receiveEndpointContext.ReceiveObservers.PostReceive(context).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                await _receiveEndpointContext.ReceiveObservers.ReceiveFault(context, ex).ConfigureAwait(false);
            }
            finally
            {
                context.Dispose();
            }
        }
예제 #2
0
        async Task IEventDataReceiver.Handle(EventData message, Action <ReceiveContext> contextCallback)
        {
            var context = new EventDataReceiveContext(_inputAddress, message, _receiveObservers, _receiveTopology);

            contextCallback?.Invoke(context);

            try
            {
                await _receiveObservers.PreReceive(context).ConfigureAwait(false);

                await _receivePipe.Send(context).ConfigureAwait(false);

                await context.CompleteTask.ConfigureAwait(false);

                await _receiveObservers.PostReceive(context).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                await _receiveObservers.ReceiveFault(context, ex).ConfigureAwait(false);
            }
            finally
            {
                context.Dispose();
            }
        }
예제 #3
0
        public async Task Handle(ProcessEventArgs eventArgs, CancellationToken cancellationToken)
        {
            if (!eventArgs.HasEvent)
            {
                return;
            }

            var context = new EventDataReceiveContext(eventArgs, _context, _lockContext);

            CancellationTokenRegistration registration;

            if (cancellationToken.CanBeCanceled)
            {
                registration = cancellationToken.Register(context.Cancel);
            }

            try
            {
                await _dispatcher.Dispatch(context, context).ConfigureAwait(false);
            }
            finally
            {
                registration.Dispose();
                context.Dispose();
            }
        }
예제 #4
0
        async Task IEventDataReceiver.Handle(EventData message, Action <ReceiveContext> contextCallback)
        {
            var context = new EventDataReceiveContext(message, _context);

            contextCallback?.Invoke(context);

            try
            {
                await _dispatcher.Dispatch(context).ConfigureAwait(false);
            }
            finally
            {
                context.Dispose();
            }
        }
예제 #5
0
        async Task Handle(ProcessEventArgs eventArgs)
        {
            if (!eventArgs.HasEvent)
            {
                return;
            }

            var context = new EventDataReceiveContext(eventArgs, _context, _processorContext);

            try
            {
                await _dispatcher.Dispatch(context, context).ConfigureAwait(false);
            }
            finally
            {
                context.Dispose();
            }
        }
예제 #6
0
        async Task IEventDataReceiver.Handle(EventData message, CancellationToken cancellationToken, Action <ReceiveContext> contextCallback)
        {
            var context = new EventDataReceiveContext(message, _context);

            contextCallback?.Invoke(context);

            CancellationTokenRegistration registration;

            if (cancellationToken.CanBeCanceled)
            {
                registration = cancellationToken.Register(context.Cancel);
            }

            try
            {
                await _dispatcher.Dispatch(context).ConfigureAwait(false);
            }
            finally
            {
                registration.Dispose();
                context.Dispose();
            }
        }