public bool SendMessage(MQProtocol <M> message, string hostName) { var routeKey = GetRouter(message.RouterKey, hostName); var host = MQHostConfigManager.GetHost(hostName); return(MQManager <M> .Publish(message, routeKey, host)); }
/// <summary> /// 保存异步消息,并设置初始处理状态 /// </summary> /// <param name="valueArgs">参数</param> /// <returns>是否成功</returns> public static bool SetMessage(SetBackGroudMessageArgs valueArgs) { var msg = new MQProtocol <SetBackGroudMessageArgs>("SetBackGroudMessage", valueArgs, valueArgs.Args.rid); var routeKey = GetRouter(valueArgs.BussinessType); var mq = MQManager <SetBackGroudMessageArgs> .Publish(msg, routeKey); if (!mq) { logger.LogError($"BackGroundMessageMgr.SetMessage.MQ.Error.rid = {valueArgs.Args.rid}"); return(false); } logger.LogInformation($"BackGroundMessageMgr.SetMessage.MQ.Success.rid = {valueArgs.Args.rid}"); var processMsg = new BackGroundMessageProcessResult() // 初始化一个未开始状态,所有值都为-1,表示还在队列中,未开始 { ProcessNum = -1, SuccessNum = -1, TotalNum = -1, Data = string.Empty, Rid = valueArgs.Args.rid, }; return(SetProcessStatus(processMsg)); }
/// <summary> /// 发现点对点消息 /// </summary> /// <param name="valueArgs">参数</param> /// <returns>是否成功</returns> public static bool SetDirectMessage(SetBackGroudMessageArgs valueArgs) { var msg = new MQProtocol <SetBackGroudMessageArgs>("SetDirectMessage", valueArgs, valueArgs.Args.rid); var routeKey = BackGroundDirectMessage.GetRouter(valueArgs.MQRouterName); var mq = MQManager <SetBackGroudMessageArgs> .Publish(msg, routeKey); if (!mq) { logger.LogError($"SuperDirectMessageHelper.SetDirectMessage.MQ.Error.rid = {valueArgs.Args.rid}"); return(false); } logger.LogInformation($"SuperDirectMessageHelper.SetDirectMessage.MQ.Success.rid = {valueArgs.Args.rid}"); return(true); }