public void Vistor(TopicName topicName, MqCommandInfo commandInfo) { if (topicName != TopicName.PushMessage && commandInfo.MessageType != NMSMessageType.AutoUpdateInfo) { return; } var data = JsonUtils.Deserialize <MqAutoUpdateInfo>(commandInfo.Body); if (data == null) { _logger.Error("自动更新数据包无效 Body:" + commandInfo.Body); return; } if (data.AppType != AppType.MqListener) { _logger.Error("自动更新AppType无效:" + data.AppType.ToString() + " Body:" + commandInfo.Body); return; } var clientId = ProcessLockHelper.GetProcessLockId(); if (!string.Equals(clientId, data.AppId, StringComparison.OrdinalIgnoreCase)) { _logger.Error("自动更新数据包客户ID不匹配" + data.AppId + " Body:" + commandInfo.Body); return; } AutoUpdaterInfo info = AutoUpdaterInfo.Current; UpdateListener(info, data); }
/// <summary> /// /// </summary> /// <param name="configInfo"></param> public ActiveMqdlqMqListenerService(MqInstanceInfo configInfo) { _logger = LoggerFactory.GetLog(); ClientId = ProcessLockHelper.GetProcessLockId() + "_MqId:" + configInfo.MqInstanceId; ServiceName = "Mq监听服务" + ClientId; _configInfo = configInfo; Started += OnStarted; Stoping += OnStoping; }
/// <summary> /// /// </summary> /// <param name="clientid"></param> /// <returns></returns> public AppBasicInfo GetOrRegisterListener(string clientid) { var computername = ProcessLockHelper.GetRunningComputerName(); var data = GetOrRegister(null, AppType.MqListener, clientid, computername, ProcessLockHelper.GetIpAddresses(), ProcessLockHelper.GetRunningMacAddress(), ProcessLockHelper.GetProcessDirectoryName(), AutoUpdaterInfo.Current.Version); return(data); }
/// <summary> /// /// </summary> /// <param name="configCenterService"></param> /// <param name="topicVistors"></param> /// <param name="queueVistors"></param> public MqListenerFactoryThreadService( IMqConfigService configCenterService, IConfigCenterMqListenerService listenerService, IEnumerable <IMqCommandTopicVistor> topicVistors, IEnumerable <IMqCommandQuqueVistor> queueVistors) { _listenerAppId = ProcessLockHelper.GetProcessLockId(); _configCenterMqListenerService = listenerService; _cacheManager = new FileCacheManager <ConcurrentDictionary <int, MqInstanceInfo> >((int)CacheRegionName.FileMqDeleteInstace); this._configCenterService = configCenterService; _topicVistors = topicVistors; _queueVistors = queueVistors; _serviceList = new ConcurrentDictionary <int, MqListenerService>(); _delInstanceInfos = new ConcurrentDictionary <int, MqInstanceInfo>(); _excuteInfoDictionary = new ConcurrentDictionary <string, ExcuteInfo>(); Stoped += OnStoped; Stoping += OnStoping; Starting += OnStarting; }
static void Main(string[] args) { var lockerid = ProcessLockHelper.GetProcessLockId(); try { Console.Title = "消息调度程序 " + lockerid.Substring(0, 6); bool isCreated; string mutexName = lockerid; var appMutex = new Mutex(true, mutexName, out isCreated); //如果创建失败,则表示已经运行了。 if (!isCreated) { Console.WriteLine("已经运行,按任意键结束!"); Console.Read(); } else { Console.WriteLine("正在启动中"); CommonUnitity.Init(false); RedisBase.Initialize(new RedisConfigService()); TCSoftServiceBus.Current.Start(); Console.WriteLine("服务总线启动成功"); while ((Console.ReadKey().Key != ConsoleKey.Q)) { continue; } TCSoftServiceBus.Current.Stop(); Console.WriteLine("结束允许"); appMutex.ReleaseMutex(); appMutex.Dispose(); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.Read(); } }