public async Task Handle(ConsumeResult <TKey, TValue> result, CancellationToken cancellationToken) { var context = new ConsumeResultReceiveContext <TKey, TValue>(result, _context, _lockContext, _headersDeserializer); CancellationTokenRegistration registration; if (cancellationToken.CanBeCanceled) { registration = cancellationToken.Register(context.Cancel); } try { await _dispatcher.Dispatch(context, context).ConfigureAwait(false); } finally { registration.Dispose(); context.Dispose(); } }
async Task Handle(ConsumeResult <TKey, TValue> result) { if (IsStopping) { return; } var context = new ConsumeResultReceiveContext <TKey, TValue>(result, _context, _consumerContext, _consumerContext.HeadersDeserializer); try { await _dispatcher.Dispatch(context, context).ConfigureAwait(false); } catch (Exception exception) { context.LogTransportFaulted(exception); } finally { context.Dispose(); } }