public async override Task OnMessageAsync(T message, IMessageFeedbackSender feedbackSender, CancellationToken cancellationToken) { var invocationSuccess = false; var exceptions = new List <Exception>(); var tryCount = 0; while (tryCount == 0 || (!invocationSuccess && ShouldRetry(tryCount, exceptions))) { if (tryCount > 0 && InvokeRetryWaitMilliseconds > 0) { await Task.Delay(InvokeRetryWaitMilliseconds, cancellationToken).ConfigureAwait(false); } tryCount++; invocationSuccess = await TryInvokeAsync(message, exceptions, cancellationToken).ConfigureAwait(false); } if (invocationSuccess) { feedbackSender.Ack(); } else if (ShouldRequeue(exceptions)) { feedbackSender.Nack(true); } else { feedbackSender.Nack(false); } }
public override void OnMessage(object message, IMessageFeedbackSender feedbackSender) { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.TargetObject = this.Service; methodInvoker.TargetMethod = this.ServiceMethod; methodInvoker.Arguments = new object[] { message }; methodInvoker.Prepare(); bool invocationSuccess = false; var exceptions = new List <Exception>(); int tryCount = 0; while (tryCount == 0 || (!invocationSuccess && this.ShouldRetry(tryCount, exceptions))) { if (tryCount > 0 && this.InvokeRetryWaitMilliseconds > 0) { Thread.Sleep(this.InvokeRetryWaitMilliseconds); } tryCount++; this.TryInvoke(methodInvoker, exceptions, out invocationSuccess); } if (invocationSuccess) { feedbackSender.Ack(); } else if (this.ShouldRequeue(exceptions)) { feedbackSender.Nack(true); } else { feedbackSender.Nack(false); } }
public override Task OnMessageAsync(T message, IMessageFeedbackSender feedbackSender, CancellationToken cancellationToken) { try { CallbackAction(message); feedbackSender.Ack(); } catch (Exception) { feedbackSender.Nack(true); } return(Task.FromResult(0)); }
public async override Task OnMessageAsync(T message, IMessageFeedbackSender feedbackSender, CancellationToken cancellationToken) { try { var tokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); tokenSource.CancelAfter(_processingTimeout); await _callbackFunc(message, tokenSource.Token).ConfigureAwait(false); feedbackSender.Ack(); } catch (Exception) { feedbackSender.Nack(true); } }
public virtual void OnMessage(object message, IMessageFeedbackSender feedbackSender) { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.TargetObject = this.Service; methodInvoker.TargetMethod = this.ServiceMethod; methodInvoker.Arguments = new object[] { message }; methodInvoker.Prepare(); try { object returnValue = methodInvoker.Invoke(); feedbackSender.Ack(); } catch (Exception) { feedbackSender.Nack(true); } }