Exemple #1
0
 /// <summary>
 /// 启动
 /// </summary>
 /// <param name="args"></param>
 protected override void OnStart(string[] args)
 {
     try
     {
         _logger           = BrEngineContext.Current.Resolve <ILogger>();
         mqConfig          = MQConfigSection.GetConfig();
         MQEntity          = new MQEntity();
         MQEntity.Uri      = "failover:tcp://" + mqConfig.Host + ":" + mqConfig.Port;
         MQEntity.Topic    = mqConfig.TopicName;
         MQEntity.UserName = mqConfig.UserName;
         MQEntity.Password = mqConfig.Password;
         MQEntity.Start();
         Consumer           = MQEntity.CreateConsumerQueue(MQEntity.Topic);
         Consumer.Listener += new MessageListener(ConsumerListener);
         _logger.Error(typeof(OrderMQService), "*****************初始化监听订单消息队列成功******************");
     }
     catch (Exception ex)
     {
         _logger.Error(typeof(OrderMQService), "*****************初始化监听订单消息队列失败******************");
     }
 }
Exemple #2
0
        /// <summary>
        /// 静态构造函数
        /// </summary>
        static OrderMQ()
        {
            try
            {
                mqConfig = MQConfigSection.GetConfig();

                MQEntity          = new MQEntity();
                MQEntity.Topic    = mqConfig.TopicName;
                MQEntity.Uri      = "failover:tcp://" + mqConfig.Host + ":" + mqConfig.Port;
                MQEntity.UserName = mqConfig.UserName;
                MQEntity.Password = mqConfig.Password;
                MQEntity.Start();
                Producer = MQEntity.CreateProducerQueue(MQEntity.Topic);
                Producer.DeliveryMode = MsgDeliveryMode.Persistent;

                _logger.Error(typeof(OrderMQ), "*****************初始化订单消息队列成功 ******************");
            }
            catch (Exception ex)
            {
                _logger.Error(typeof(OrderMQ), "*****************初始化订单消息队列失败 ******************");
            }
        }