Exemplo n.º 1
0
 public static ConfigManage GetInstance()
 {
     if (_configManage == null)
     {
         lock (locker)//确保线程安全
         {
             if (_configManage == null)
             {
                 _configManage = new ConfigManage();
                 _configManage.configOperat = new ConfigurationBuilder()
                                              .AddInMemoryCollection()
                                              .SetBasePath(Directory.GetCurrentDirectory())
                                              .AddJsonFile(_configManage.basejsonFileName, optional: true, reloadOnChange: true)
                                              .Build();
             }
         }
     }
     return(_configManage);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 创建服务总线
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static IBus CreateEventBus()
        {
            var config = ConfigManage.GetInstance().AppSettings["MeessageService"];

            if (string.IsNullOrEmpty(config))
            {
                throw new Exception("消息地址未配置");
            }
            if (bus == null && !string.IsNullOrEmpty(config))
            {
                lock (lockMq)
                {
                    if (bus == null)
                    {
                        bus = RabbitHutch.CreateBus(config);
                    }
                }
            }
            return(bus);
        }