rabbit 在.net 环境下偶现(概略率):None of the specified endpoints were
项目使用的 rabbit RabbitMQ.Client, Version=5.0.0.0
比来项目用户量上来后,偶现 None of the specified endpoints were reachable 异常
解决方案:改削MQ请求的超不时间(参数TimeoutMilliseconds 由之前的30秒改成默认10秒,个别挪用时间5秒) 颁布后系统不变
/// <summary> /// /// </summary> /// <param></param> /// <param></param> /// <param></param> /// <param></param> /// <returns></returns> public static string SendMessage(string jsonStr, string className, string actionName, string authCode, int timeout = 10000) { if (cf.HostName == null || string.IsNullOrWhiteSpace(cf.HostName) || cf.HostName == "localhost") { cf.HostName = hostName; cf.VirtualHost = virtualHost; cf.UserName = userName; cf.Password = password; } using (IConnection conn = cf.CreateConnection()) { using (IModel ch = conn.CreateModel()) { var requst = new RMQRequest { ClassName = className, ActionName = actionName, JStr = jsonStr, Timestamp = DateTime.Now }; object[] reqobj = new object[1]; reqobj[0] = JsonConvert.SerializeObject(requst); SimpleRpcClient client = new SimpleRpcClient(ch, authCode); client.TimeoutMilliseconds = timeout; client.TimedOut += new EventHandler(TimedOutHandler); client.Disconnected += new EventHandler(DisconnectedHandler); var reply = client.Call(reqobj); if (reply == null) { return null; } else { return reply[0].ToString(); } } } }
rabbit 在.net 环境下偶现(概略率):None of the specified endpoints were reachable 异常
标签:
原文地点:https://www.cnblogs.com/WQ1992/p/12100854.html
,温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/33014.html