Пример #1
0
        /// <summary>
        /// 处理发送来的日志
        /// </summary>
        /// <param name="obj"></param>
        private void MessageConsumer_MessageReceivedEvent(object obj, string queueName, ulong deliveryTag)
        {
            var log = obj as LogRequest;

            if (log == null)
            {
                //让消息重新回到队列
                RabbitMqMessageManage.SendReceivedResult(queueName, deliveryTag, false);
                Logger.Error($"队列消息反序列化失败:{obj.ToJson()}");
                return;
            }
            //将日志写入MogoDb
            Logger.Info($"从队列中读取了消息:{obj.ToJson()}");
            var res = SaveLog(queueName, log);

            if (res)
            {
                RabbitMqMessageManage.SendReceivedResult(queueName, deliveryTag, true);
            }
            else
            {
                RabbitMqMessageManage.SendReceivedResult(queueName, deliveryTag, false);
            }
        }
Пример #2
0
        public void StartGetMsg(LogLevel level)
        {
            var queueName = level.ToString();

            RabbitMqMessageManage.StartGet <LogRequest>(queueName);
        }