private IHandlerAsync <T> MaybeWrapWithExactlyOnce <T>(IHandlerAsync <T> handler) where T : Message { var handlerType = handler.GetType(); var exactlyOnceMetadata = new ExactlyOnceReader(handlerType); if (!exactlyOnceMetadata.Enabled) { return(handler); } if (_messageLock == null) { throw new Exception("IMessageLock is null. You need to specify an implementation for IMessageLock."); } var handlerName = handlerType.FullName.ToLower(); return(new ExactlyOnceHandler <T>(handler, _messageLock, exactlyOnceMetadata.GetTimeOut(), handlerName)); }
private IHandlerAsync <T> MaybeWrapWithExactlyOnce <T>(IHandlerAsync <T> handler) where T : Message { var handlerType = handler.GetType(); var exactlyOnceMetadata = new ExactlyOnceReader(handlerType); if (!exactlyOnceMetadata.Enabled) { return(handler); } if (_messageLock == null) { throw new Exception("IMessageLock is null. You need to specify an implementation for IMessageLock."); } var handlerName = handlerType.FullName.ToLowerInvariant(); var timeout = TimeSpan.FromSeconds(exactlyOnceMetadata.GetTimeOut()); var logger = _loggerFactory.CreateLogger <ExactlyOnceHandler <T> >(); return(new ExactlyOnceHandler <T>(handler, _messageLock, timeout, handlerName, logger)); }