/// <summary> /// Initializes a new instance of the <see cref="MessageExceptionHandler"/> class. /// </summary> /// <param name="transportErrorHandler">The transport error handler.</param> /// <param name="log">The log.</param> public MessageExceptionHandler(IReceiveMessagesError transportErrorHandler, ILogFactory log) { Guard.NotNull(() => transportErrorHandler, transportErrorHandler); Guard.NotNull(() => log, log); _transportErrorHandler = transportErrorHandler; _log = log.Create(); }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveMessagesErrorDecorator" /> class. /// </summary> /// <param name="metrics">The metrics factory.</param> /// <param name="handler">The handler.</param> /// <param name="connectionInformation">The connection information.</param> public ReceiveMessagesErrorDecorator(IMetrics metrics, IReceiveMessagesError handler, IConnectionInformation connectionInformation) { var name = handler.GetType().Name; _meterError = metrics.Meter($"{connectionInformation.QueueName}.{name}.MessageFailedProcessingErrorMeter", Units.Items); _meterRetry = metrics.Meter($"{connectionInformation.QueueName}.{name}.MessageFailedProcessingRetryMeter", Units.Items); _handler = handler; }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveMessagesErrorDecorator" /> class. /// </summary> /// <param name="metrics">The metrics factory.</param> /// <param name="handler">The handler.</param> /// <param name="connectionInformation">The connection information.</param> public ReceiveMessagesErrorDecorator(IMetrics metrics, IReceiveMessagesError handler, IConnectionInformation connectionInformation) { var name = "ReceiveMessagesError"; _meterError = metrics.Meter($"{connectionInformation.QueueName}.{name}.MessageFailedProcessingErrorMeter", Units.Items); _meterRetry = metrics.Meter($"{connectionInformation.QueueName}.{name}.MessageFailedProcessingRetryMeter", Units.Items); _handler = handler; }
public void Message_Handled_Exception_Throws_Exception() { var fixture = new Fixture().Customize(new AutoNSubstituteCustomization()); IReceiveMessagesError error = fixture.Create <ReceiveMessagesErrorWillCrash>(); fixture.Inject(error); var test = new MessageExceptionHandler(error, Substitute.For <ILogger>()); var message = fixture.Create <IReceivedMessageInternal>(); var context = fixture.Create <IMessageContext>(); var exception = new Exception(); Assert.Throws <DotNetWorkQueueException>( delegate { test.Handle(message, context, exception); }); }
/// <summary> /// Initializes a new instance of the <see cref="ReceiveMessagesErrorDecorator"/> class. /// </summary> /// <param name="handler">The handler.</param> /// <param name="tracer">The tracer.</param> /// <param name="headers">The headers.</param> public ReceiveMessagesErrorDecorator(IReceiveMessagesError handler, ITracer tracer, IStandardHeaders headers) { _handler = handler; _tracer = tracer; _headers = headers; }