public async Task OnBeforeConsumeAsync <TMessage, TConsumer>(IConsumeAsync <TMessage> consumer, TMessage message) where TMessage : class where TConsumer : IConsumeAsync <TMessage>
        {
            if (!CreateStateHandlerIfConsumerRequiresState <TConsumer, TMessage>())
            {
                return;
            }

            await handler.LoadStateAsync(consumer, message);
        }
 public Task OnAfterConsumeAsync <TMessage, TConsumer>(IConsumeAsync <TMessage> consumer, TMessage message) where TMessage : class where TConsumer : IConsumeAsync <TMessage>
 {
     return(Task.Factory.StartNew(() =>
     {
         if (_lock != null)
         {
             _lock.Dispose();
         }
     }));
 }
        public async Task OnBeforeConsumeAsync <TMessage, TConsumer>(IConsumeAsync <TMessage> consumer, TMessage message) where TMessage : class where TConsumer : IConsumeAsync <TMessage>
        {
            var requiresLocking = typeof(TConsumer).IsOfGenericType(typeof(IConsumeLocked <>));

            if (!requiresLocking)
            {
                return;
            }

            _lock = await locker.AcquireLockAsync(GetCorrelationIdentifier <TMessage, TConsumer>(message));
        }
 public async Task OnAfterConsumeAsync <TMessage, TConsumer>(IConsumeAsync <TMessage> consumer, TMessage message) where TMessage : class where TConsumer : IConsumeAsync <TMessage>
 {
     await handler.SaveStateAsync(consumer, message);
 }