Exemplo n.º 1
0
        void Send(IMessageProducer producer, MapMessage message)
        {
            IMapMessage mapMessage = producer.CreateMapMessage();

            foreach (string key in message.Properties.Keys)
            {
                mapMessage.Properties[key] = message.Properties[key];
            }

            foreach (string key in message.Body.Keys)
            {
                mapMessage.Body[key] = message.Body[key];
            }

            _logger.DebugFormat("开始向 {0} 发送消息", _nm);
            try
            {
                if (isFirst)
                {
                    DateTime old = DateTime.Now;
                    producer.Send(mapMessage);
                    isFast = ((DateTime.Now - old) < TimeSpan.FromSeconds(1));
                    if (!isFast)
                    {
                        _logger.DebugFormat("向 {0} 发送消息发现耗时太长, 决定以后跳过!", _nm);
                    }

                    isFirst = false;
                }
                else if (isFast)
                {
                    producer.Send(mapMessage);
                    _logger.DebugFormat("向 {0} 发送消息完成", _nm);
                }
                else
                {
                    throw new ApplicationException("发送消息耗时太长, 决定跳过");
                }
            }
            catch (Exception e)
            {
                if (_logger.IsDebugEnabled)
                {
                    _logger.Debug(string.Format("向 {0} 发送消息发生错误", _nm), e);
                }
                throw;
            }
        }
Exemplo n.º 2
0
        public void Send(Destination destination, MapMessage message)
        {
            _default.Send(destination, message);

            _laseErrors.Clear();

            foreach (InternalSession session in _sessions)
            {
                try
                {
                    session.Send(destination, message);
                }
                catch (Exception e)
                {
                    _laseErrors.Add(new Error(session.Name, e));
                }
            }
        }
Exemplo n.º 3
0
        public void Send(Destination destination, MapMessage message)
        {
            if (null != this.e)
            {
                throw this.e;
            }
            switch (destination)
            {
            case Destination.ALERT:
                if (null == alertProducer)
                {
                    alertProducer = this.session.CreateProducer(alertDestination);
                }
                Send(alertProducer, message);
                return;

            case Destination.DESKTERMINAL:
                if (null == deskTerminalProducer)
                {
                    deskTerminalProducer = this.session.CreateProducer(deskTerminalDestination);
                }
                Send(deskTerminalProducer, message);
                return;

            case Destination.MODEL:
                if (null == modelProducer)
                {
                    modelProducer = this.session.CreateProducer(modeldestination);
                }
                Send(modelProducer, message);
                return;

            case Destination.PERFORMANCE:
                if (null == performanceProducer)
                {
                    performanceProducer = this.session.CreateProducer(performanceDestination);
                }
                Send(performanceProducer, message);
                return;
            }
            throw new ArgumentOutOfRangeException();
        }
Exemplo n.º 4
0
        public void Send(Destination destination, MapMessage message)
        {
            _default.Send(destination, message);

            _laseErrors.Clear();

            foreach (InternalSession session in _sessions)
            {
                try
                {
                    session.Send(destination, message);
                }
                catch (Exception e)
                {
                    _laseErrors.Add(new Error(session.Name, e));
                }
            }
        }
Exemplo n.º 5
0
        void Send(IMessageProducer producer, MapMessage message)
        {
            IMapMessage mapMessage = producer.CreateMapMessage();
            foreach (KeyValuePair<string, object> kp in message.Properties)
            {
                mapMessage.Properties[kp.Key] = kp.Value;
            }

            foreach (KeyValuePair<string, object> kp in message.Body)
            {
                mapMessage.Body[kp.Key] = kp.Value;
            }

            _logger.DebugFormat("开始向 {0} 发送消息", _nm);
            try
            {
                if (isDefault)
                {
                    producer.Send(mapMessage);
                }
                else if (isFast)
                {
                    DateTime old = DateTime.Now;
                    producer.Send(mapMessage);
                    isFast = ((DateTime.Now - old) < TimeSpan.FromSeconds(1));
                    if (!isFast)
                        _logger.DebugFormat("向 {0} 发送消息发现耗时太长, 决定以后跳过!", _nm);
                }
                else
                {
                    throw new ApplicationException("发送消息耗时太长, 决定跳过");
                }

            }
            catch (Exception e)
            {
                if (_logger.IsDebugEnabled)
                    _logger.Debug(string.Format("向 {0} 发送消息发生错误", _nm), e);
                throw;
            }
        }
Exemplo n.º 6
0
 public void Send(Destination destination, MapMessage message)
 {
     if (null != this.e)
         throw this.e;
     switch (destination)
     {
         case Destination.ALERT:
             if (null == alertProducer)
                 alertProducer = this.session.CreateProducer(alertDestination);
             Send(alertProducer, message);
             return;
         case Destination.DESKTERMINAL:
             if (null == deskTerminalProducer)
                 deskTerminalProducer = this.session.CreateProducer(deskTerminalDestination);
             Send(deskTerminalProducer, message);
             return;
         case Destination.MODEL:
             if (null == modelProducer)
                 modelProducer = this.session.CreateProducer(modeldestination);
             Send(modelProducer, message);
             return;
         case Destination.PERFORMANCE:
             if (null == performanceProducer)
                 performanceProducer = this.session.CreateProducer(performanceDestination);
             Send(performanceProducer, message);
             return;
     }
     throw new ArgumentOutOfRangeException();
 }