public MessageHandlerDescriptor(IMessageHandlerAsync <T> handler, Type type) { _handle = p => Task.Run(async() => await handler.HandleAsync(p).ConfigureAwait(false)) .Wait(TimeSpan.FromSeconds(30)); ParameterType = type; }
/// <summary> /// Initializes a new instance of the <see cref="QueueCreationDecorator" /> class. /// </summary> /// <param name="metrics">The metrics factory.</param> /// <param name="handler">The handler.</param> /// <param name="connectionInformation">The connection information.</param> public MessageHandlerAsyncDecorator(IMetrics metrics, IMessageHandlerAsync handler, IConnectionInformation connectionInformation) { var name = handler.GetType().Name; _runCodeTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.HandleTimer", Units.Calls); _handler = handler; }
/// <summary> /// Initializes a new instance of the <see cref="HandleMessage" /> class. /// </summary> /// <param name="messageHandler">The message handler.</param> /// <param name="messageHandlerAsync">The message handler asynchronous.</param> public HandleMessage(IMessageHandler messageHandler, IMessageHandlerAsync messageHandlerAsync) { Guard.NotNull(() => messageHandler, messageHandler); Guard.NotNull(() => messageHandlerAsync, messageHandlerAsync); _messageHandler = messageHandler; _messageHandlerAsync = messageHandlerAsync; }
/// <summary> /// Initializes a new instance of the <see cref="QueueCreationDecorator" /> class. /// </summary> /// <param name="metrics">The metrics factory.</param> /// <param name="handler">The handler.</param> /// <param name="connectionInformation">The connection information.</param> public MessageHandlerAsyncDecorator(IMetrics metrics, IMessageHandlerAsync handler, IConnectionInformation connectionInformation) { var name = "MessageHandlerAsync"; _runCodeTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.HandleTimer", Units.Calls); _handler = handler; }
private IMessageHandlerAsync <T> Decorate <T>(IMessageHandlerAsync <T> messageHandler) where T : IMessage { #if DEBUG return(new SuppressAsyncExceptionDecorator <T>( new DebugShowErrorMessageDecorator <T>( new DebugShowDurationMessageDecorator <T>(new PerLoggerMessageDecorator <T>(messageHandler), _sessionManager), _sessionManager), _logger)); #else return(new SuppressAsyncExceptionDecorator <T>(new PerLoggerMessageDecorator <T>(messageHandler), _logger)); #endif }
public RabbitMQListenerServiceAsync( IHostApplicationLifetime appLifetime, ILogger <RabbitMQListenerServiceAsync <T> > logger, IMessageHandlerAsync <T> messageHandler, IOptionsMonitor <RabbitMQOptions> options) { _appLifetime = appLifetime; _logger = logger; _messageHandler = messageHandler; _options = options.CurrentValue; if (string.IsNullOrWhiteSpace(_options.ConnectionString)) { _logger.LogError("RabbitMQ connection string is missing."); throw new Exception("Missing connection string."); } }
public DebugShowErrorMessageDecorator(IMessageHandlerAsync <T> decorated, ISessionManager sessionManager) { _decorated = decorated; _debugMessageManager = new DebugMessageManager(sessionManager); }
/// <summary> /// Initializes a new instance of the <see cref="MessageHandlerAsyncDecorator"/> class. /// </summary> /// <param name="handler">The handler.</param> /// <param name="tracer">The tracer.</param> /// <param name="headers">The headers.</param> public MessageHandlerAsyncDecorator(IMessageHandlerAsync handler, ITracer tracer, IHeaders headers) { _handler = handler; _tracer = tracer; _headers = headers; }
public SuppressAsyncExceptionDecorator(IMessageHandlerAsync <T> decorated, ILogger logger) { _decorated = decorated; _logger = logger; }
public PerLoggerMessageDecorator(IMessageHandlerAsync <T> decorated) { _decorated = decorated; }
public void Subscribe <T>(IMessageHandlerAsync <T> handler) where T : IMessage { _handlers.Add(new MessageHandlerDescriptor <T>(handler, typeof(T))); }
/// <summary> /// Initializes a new instance of the <see cref="MessageHandlerAsyncDecorator"/> class. /// </summary> /// <param name="handler">The handler.</param> /// <param name="tracer">The tracer.</param> /// <param name="headers">The headers.</param> public MessageHandlerAsyncDecorator(IMessageHandlerAsync handler, ActivitySource tracer, IHeaders headers) { _handler = handler; _tracer = tracer; _headers = headers; }
public static IMediator SubscribeAsync <TMessage>(this IMediator mediator, IMessageHandlerAsync <TMessage> handler) => mediator.SubscribeAsync <TMessage>(message => handler.Handle(message));