private static void HandleTransientErrors(MessagingException e) { //If transient error/exception, let's back-off for 2 seconds and retry Console.WriteLine(e.Message); Console.WriteLine("Will retry sending the message in 2 seconds"); Thread.Sleep(2000); }
public void HandleTransientError() { var ex = new MessagingException(Guid.NewGuid().ToString()); var h = new TransientErrorHandler(); h.TransientErrorOccured += h_TransientErrorOccured; h.HandleTransientError(ex); Assert.AreEqual(ex, this.exception); }
public void Exception() { var expected = new MessagingException(Guid.NewGuid().ToString()); var args = new TransientErrorArgs { Exception = expected, }; Assert.AreEqual(expected, args.Exception); }
public void HandleTransientError() { this.exception = null; var ex = new MessagingException("hahaha"); var bq = new BusQueue(Guid.NewGuid().ToString(), connection); bq.TransientErrorOccured += this.Error; bq.HandleTransientError(ex); Assert.AreEqual(ex, this.exception); }
public static bool IsCommon(MessagingException messagingException) { var inner = messagingException; while (inner != null) { if (inner.IsTransient || inner is MessagingEntityAlreadyExistsException) { return true; } inner = inner.InnerException as MessagingException; } return false; }
/// <summary> /// Handle Transient Error /// </summary> /// <param name="ex">Messaging Exception</param> public virtual void HandleTransientError(MessagingException ex) { if (null != ex) { var handle = this.TransientErrorOccured; if (null != handle) { var arg = new TransientErrorArgs { Exception = ex, }; handle(this, arg); } Trace.TraceWarning("Transient Error: '{0}'", ex.ToString()); } }
public static bool IsRetryable(MessagingException messagingException) { var inner = messagingException; while (inner != null) { if (inner.IsTransient || inner is MessagingEntityDisabledException) { return true; } inner = inner.InnerException as MessagingException; } return false; }
public void HandleError(Exception ex) { MessagingException messagingException = ex as MessagingException; IMessage failedMessage = messagingException == null ? null : messagingException.FailedMessage; IMessageChannel errorChannel = ResolveErrorChannel(failedMessage); bool sent = false; if (errorChannel != null) { try { if (_sendTimeout.TotalMilliseconds >= 0) { sent = errorChannel.Send(new ErrorMessage(ex), _sendTimeout); } else { sent = errorChannel.Send(new ErrorMessage(ex)); } } catch (Exception errorDeliveryError) { // message will be logged only if (logger.IsWarnEnabled) { logger.Warn("Error message was not delivered.", errorDeliveryError); } } } if (!sent && logger.IsErrorEnabled) { if (failedMessage != null) { logger.Error("failure occurred in messaging task with message: " + failedMessage, ex); } else { logger.Error("failure occurred in messaging task", ex); } } }
public static bool IsRetryable(MessagingException messagingException) { var inner = messagingException; while (inner != null) { if (inner.IsTransient || inner is QuotaExceededException || inner is DuplicateMessageException || inner is MessageLockLostException || inner is MessageNotFoundException || inner is MessagingEntityAlreadyExistsException || inner is MessagingEntityDisabledException || inner is SessionLockLostException) { return true; } inner = inner.InnerException as MessagingException; } return false; }
private CommunicationException OnException(Exception exception) { if (Fx.IsFatal(exception)) { return(null); } MessagingException messagingException = exception as MessagingException; MessagingException messagingException1 = messagingException; if (messagingException != null) { return(this.HandleMessagingException(messagingException1)); } if (exception is OperationCanceledException) { MessagingException innerException = exception.InnerException as MessagingException; if (innerException != null) { return(this.HandleMessagingException(innerException)); } } return(null); }
protected override void OnEndClose(IAsyncResult result) { try { this.MessagingFactory.EndClose(result); } catch (MessagingException messagingException1) { MessagingException messagingException = messagingException1; throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(this.ConvertException(messagingException), null); } catch (OperationCanceledException operationCanceledException1) { OperationCanceledException operationCanceledException = operationCanceledException1; ExceptionTrace exception = Microsoft.ServiceBus.Messaging.FxTrace.Exception; string entityClosedOrAborted = SRClient.EntityClosedOrAborted; Exception innerException = operationCanceledException.InnerException; if (innerException == null) { innerException = operationCanceledException; } throw exception.AsError(new CommunicationObjectAbortedException(entityClosedOrAborted, innerException), null); } }
public void Send(Message message, TimeSpan timeout) { bool flag; bool flag1; if (message == null) { throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.ArgumentNull("message"); } TimeoutHelper.ThrowIfNegativeArgument(timeout); base.ThrowIfDisposedOrNotOpen(); this.AddHeadersTo(message); this.TraceSendingMessage(message); byte[] numArray = null; BrokeredMessage brokerMessage = null; try { try { brokerMessage = this.ConvertToBrokerMessage(message, out numArray); this.MessageSender.Send(new BrokeredMessage[] { brokerMessage }, timeout); } catch (MessagingException messagingException) { CommunicationException communicationException = MessagingExceptionHelper.ConvertToCommunicationException(messagingException, out flag); if (flag) { base.Fault(); } throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(communicationException, null); } catch (OperationCanceledException operationCanceledException1) { OperationCanceledException operationCanceledException = operationCanceledException1; MessagingException innerException = operationCanceledException.InnerException as MessagingException; if (innerException != null) { MessagingExceptionHelper.ConvertToCommunicationException(innerException, out flag1); if (flag1) { base.Fault(); } } ExceptionTrace exception = Microsoft.ServiceBus.Messaging.FxTrace.Exception; string entityClosedOrAborted = SRClient.EntityClosedOrAborted; Exception innerException1 = operationCanceledException.InnerException; if (innerException1 == null) { innerException1 = operationCanceledException; } throw exception.AsError(new CommunicationObjectAbortedException(entityClosedOrAborted, innerException1), null); } } finally { if (brokerMessage != null && numArray != null) { this.ChannelFactory.BufferManager.ReturnBuffer(numArray); } } }
public MessagingExceptionWrapperException(IMessage originalMessage, MessagingException cause) : base(originalMessage, cause) { }
private static void HandleTransientErrors(MessagingException e) { //If transient error/exception, let's back-off for 2 seconds and retry Thread.Sleep(2000); }
public void HandleTransientErrorNull() { this.exception = null; var ex = new MessagingException("hahaha"); var bq = new TopicSender(Guid.NewGuid().ToString(), connection); bq.TransientErrorOccured += this.Error; bq.HandleTransientError(null); Assert.IsNull(this.exception); }
private void ManipularExcecoes(MessagingException e) { lstMensagens.Items.Add("status: " + e.Message); lstMensagens.Items.Add("status: TentarĂ¡ enviar a mensagem em 2 segundos..."); Thread.Sleep(2000); }
private static void ReturnGoneIfHubResponseIsGone(MessagingException e) { var webex = e.InnerException as WebException; if (webex.Status == WebExceptionStatus.ProtocolError) { var response = (HttpWebResponse)webex.Response; if (response.StatusCode == HttpStatusCode.Gone) throw new HttpRequestException(HttpStatusCode.Gone.ToString()); } }
public virtual void Publish(IMessage inputMessage, MessagingException exception) { Publish(inputMessage, exception.FailedMessage, exception); }
private static void ManipularErros(MessagingException error) { Console.WriteLine(error.Message); Console.WriteLine("TentarĂ¡ enviar a mensagem em 2 segundos"); Thread.Sleep(2000); }
public virtual void Publish(MessagingException exception) { Publish(null, exception.FailedMessage, exception); }
private static void HandleTransientErrors(MessagingException e) { //If transient error/exception, let's back-off for 2 seconds and retry Console.WriteLine("Will retry sending the message in 2 seconds"); Thread.Sleep(2000); }