/// <summary> /// Tries the process a new incoming message. /// </summary> /// <returns></returns> private async Task TryProcessIncomingMessageAsync() { using (var context = _messageContextFactory.Create()) { try { await DoTryAsync(context).ConfigureAwait(false); } catch (OperationCanceledException) { _rollbackMessage.Rollback(context); } // ReSharper disable once UncatchableException catch (ThreadAbortException) { _rollbackMessage.Rollback(context); } catch (PoisonMessageException exception) { _receivePoisonMessage.Handle(context, exception); } catch (ReceiveMessageException e) //an exception occurred trying to get the message from the transport { _log.LogError($"An error has occurred while receiving a message from the transport{System.Environment.NewLine}{e}"); _seriousExceptionProcessBackOffHelper.Value.Wait(); } catch { _rollbackMessage.Rollback(context); throw; } } }
/// <summary> /// Tries the process the new incoming message. /// </summary> private void TryProcessIncomingMessage() { using (var context = _messageContextFactory.Create()) { try { DoTry(context); } catch (OperationCanceledException) { _rollbackMessage.Rollback(context); } // ReSharper disable once UncatchableException catch (ThreadAbortException) { _rollbackMessage.Rollback(context); } catch (PoisonMessageException exception) { _receivePoisonMessage.Handle(context, exception); } catch (ReceiveMessageException e) { //an exception occurred trying to get the message from the transport _log.ErrorException("An error has occurred while receiving a message from the transport", e, null); _seriousExceptionProcessBackOffHelper.Value.Wait(); } catch { _rollbackMessage.Rollback(context); throw; } } }
/// <inheritdoc /> public bool Rollback(IMessageContext context) { var activityContext = context.Extract(_tracer, _headers); using (var scope = _tracer.StartActivity("RollBack", ActivityKind.Internal, activityContext)) { scope?.AddMessageIdTag(context); return(_handler.Rollback(context)); } }
/// <summary> /// Rolls back the message associated to the context /// </summary> /// <param name="context"></param> /// <returns> /// true if the message was rolled back /// </returns> public bool Rollback(IMessageContext context) { var result = _handler.Rollback(context); if (result) { _rollbackCounter.Increment(); } return(result); }
/// <inheritdoc /> public bool Rollback(IMessageContext context) { var spanContext = context.Extract(_tracer, _headers); if (spanContext != null) { using (IScope scope = _tracer.BuildSpan("RollBack").AddReference(References.FollowsFrom, spanContext).StartActive(finishSpanOnDispose: true)) { return(_handler.Rollback(context)); } } else { using (IScope scope = _tracer.BuildSpan("RollBack").StartActive(finishSpanOnDispose: true)) { scope.Span.AddMessageIdTag(context); return(_handler.Rollback(context)); } } }
public bool Rollback(IMessageContext context) { try { return(_handler.Rollback(context)); } catch (Exception e) { _log.ErrorException("An error has occurred while trying to rollback a message", e, null); return(false); } }
public bool Rollback(IMessageContext context) { try { return(_handler.Rollback(context)); } catch (Exception e) { _log.LogError($"An error has occurred while trying to rollback a message{System.Environment.NewLine}{e}"); return(false); } }