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)); }