Пример #1
0
        /// <summary>
        /// 处理日志消息
        /// </summary>
        public void ProcessAuditMessage()
        {
            try
            {
                m_RabbitMQ.Listen <AuditBusiness>(Constant.ESB_AUDIT_QUEUE, x =>
                {
                    if (x != null)
                    {
                        x.InBytes       = GetStringByteLength(x.MessageBody);
                        x.OutBytes      = GetStringByteLength(x.ReturnMessageBody);
                        x.RowMethodName = GetMethodName(x.MethodName);

                        String bindingID = x.BindingTemplateID;
                        if (!String.IsNullOrWhiteSpace(bindingID))
                        {
                            BindingTemplate binding = BindingTemplate.FindByTemplateID(bindingID);
                            if (binding != null)
                            {
                                x.ServiceID = binding.ServiceID;
                                if (binding.Service != null)
                                {
                                    x.BusinessID = binding.Service.BusinessID;
                                }
                            }
                        }

                        m_MonitorStatManager.Record(x);

                        //--采用线程池将数据提交到数据库中,增加统计发布的速度。
                        ThreadPool.QueueUserWorkItem(y =>
                        {
                            x.Insert();
                        });
                    }
                });
            }
            catch (Exception ex)
            {
                XTrace.WriteLine("处理审计日志发生异常,消息将停止接收!异常详情:{0}", ex.ToString());
            }
        }