Пример #1
0
        public bool SendMessage(MQProtocol <M> message, string hostName)
        {
            var routeKey = GetRouter(message.RouterKey, hostName);
            var host     = MQHostConfigManager.GetHost(hostName);

            return(GrantMQManager <M> .Publish(message, routeKey, host));
        }
Пример #2
0
        /// <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       = GrantMQManager <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));
        }
Пример #3
0
        /// <summary>
        /// 保存异步消息,并设置初始处理状态
        /// </summary>
        /// <param name="valueArgs">参数</param>
        /// <returns>是否成功</returns>
        public static bool SetMessage(T valueArgs)
        {
            if (valueArgs == null)
            {
                return(true);
            }

            var msg      = new MQProtocol <T>("AuditMessage", valueArgs, Guid.NewGuid().ToString("N"));
            var routeKey = GetRouter(valueArgs.Ttid);
            var host     = MQHostConfigManager.GetHost("Audit");
            var mq       = GrantMQManager <T> .Publish(msg, routeKey, host);

            return(mq);
        }