Beispiel #1
0
        /// <summary>
        /// 消息侦听
        /// </summary>
        /// <param name="message"></param>
        private static void consumer_Listener(MQMessage message)
        {
            try
            {
                message.Begin();
                MQSendRequestModel obj = Newtonsoft.Json.JsonConvert.DeserializeObject <MQSendRequestModel>(message.messageContent);

                var plugin = PluginList.Find(p => p.Module == obj.MODULE);
                if (plugin != null)
                {
                    plugin.Process(EasyJson.Parse(obj.Arguments.ToString()));
                }
                else
                {
                    Logger.MQLog.Error("命令类型[" + obj.MODULE + "]未被识别!");
                }

                // Logger.MQLog.Info("消息处理:" + message.messageContent);

                message.Commit();
            }
            catch (Exception ex)
            {
                string logmsg = "消息[" + message.messageContent.ToString() + "]处理失败,准备回滚事务!原因:" + ex.Message;
                Logger.MQLog.Error(logmsg, ex);
                message.RollBack();
            }
        }