Exemplo n.º 1
0
        void options_ExceptionReceived(object sender, ExceptionReceivedEventArgs ex)
        {
            if (!data.CancelToken.IsCancellationRequested && typeof(ThreadAbortException) != ex.GetType())
            {
                //The subscription may have been deleted. If it was, then we want to recreate it.
                var subException = ex.Exception as MessagingEntityNotFoundException;

                if (subException != null && subException.Detail != null && subException.Detail.Message.IndexOf("40400") > -1)
                {
                    logger.Info("Subscription was deleted. Attempting to Recreate.");
                    Configure(endpoint);
                    retryPolicy.ExecuteAction(() => {
                        data.Client.OnMessage(OnMessageHandler, options);
                    });
                    logger.Info("Subscription was deleted. Recreated.");
                }
                else
                {
                    logger.Error(string.Format("ProcessMessagesForSubscription Message Error={0} Declared={1} MessageTytpe={2} IsReusable={3} Error={4}",
                                               data.EndPointData.SubscriptionName,
                                               data.EndPointData.DeclaredType.ToString(),
                                               data.EndPointData.MessageType.ToString(),
                                               data.EndPointData.IsReusable,
                                               ex.ToString()));
                }
            }
            else
            {
                //data.SetMessageLoopCompleted();
            }

            //TODO do something with the error we just received.
            logger.Error("Message Pump Error: Start {0} Declared {1} MessageTytpe {2}, Error {3}", data.EndPointData.SubscriptionName,
                         data.EndPointData.DeclaredType.ToString(), data.EndPointData.MessageType.ToString(), ex.Exception.ToString());
        }
Exemplo n.º 2
0
 private static async Task ExceptionHandlerAsync(ExceptionReceivedEventArgs arg)
 {
     Console.WriteLine(arg.ToString());
 }
        void options_ExceptionReceived(object sender, ExceptionReceivedEventArgs ex) {

            if (!data.CancelToken.IsCancellationRequested && typeof(ThreadAbortException) != ex.GetType()) {

                //The subscription may have been deleted. If it was, then we want to recreate it.
                var subException = ex.Exception as MessagingEntityNotFoundException;

                if (subException != null && subException.Detail != null && subException.Detail.Message.IndexOf("40400") > -1) {
                    logger.Info("Subscription was deleted. Attempting to Recreate.");
                    Configure(endpoint);
                    data.Client.OnMessage(OnMessageHandler, options);
                    logger.Info("Subscription was deleted. Recreated.");
                }
                else {
                    logger.Error(string.Format("ProcessMessagesForSubscription Message Error={0} Declared={1} MessageTytpe={2} IsReusable={3} Error={4}",
                        data.EndPointData.SubscriptionName,
                        data.EndPointData.DeclaredType.ToString(),
                        data.EndPointData.MessageType.ToString(),
                        data.EndPointData.IsReusable,
                        ex.ToString()));
                }
            }
            else {
                //data.SetMessageLoopCompleted();
            }

            //TODO do something with the error we just received.
            logger.Error("Message Pump Error: Start {0} Declared {1} MessageTytpe {2}, Error {3}", data.EndPointData.SubscriptionName,
                         data.EndPointData.DeclaredType.ToString(), data.EndPointData.MessageType.ToString(), ex.Exception.ToString());
        }
 static Task ExceptionHandler(ExceptionReceivedEventArgs arg)
 {
     Console.WriteLine(arg.ToString());
     return(Task.CompletedTask);
 }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="ex"></param>
 public void LogErrors(object sender, ExceptionReceivedEventArgs ex)
 {
     logger.Error(sender.ToString(), ex.ToString());
 }