大更新
This commit is contained in:
@@ -33,8 +33,8 @@ namespace ARI.EAP.HOST.MQ
|
||||
messageType = "Request";
|
||||
from = "EAP";
|
||||
to = "MES";
|
||||
transactionId = $"{Configuration.conf.connectSetting.name}_{System.DateTime.Now.ToString("yyyyMMddHHmmss")}" + new Random().Next(100).ToString();
|
||||
equipmentId = Configuration.conf.connectSetting.name;
|
||||
transactionId = $"{Configurations.conf.connectSetting.name}_{System.DateTime.Now.ToString("yyyyMMddHHmmss")}" + new Random().Next(100).ToString();
|
||||
equipmentId = Configurations.conf.connectSetting.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
58
MQ/Mq.cs
58
MQ/Mq.cs
@@ -36,12 +36,12 @@ namespace ARI.EAP.HOST.MQ
|
||||
{
|
||||
connectionFactory = new ConnectionFactory()
|
||||
{
|
||||
HostName = Configuration.conf.mQConnectionCfg.HostName,
|
||||
VirtualHost = Configuration.conf.mQConnectionCfg.VirtualHost,
|
||||
UserName = Configuration.conf.mQConnectionCfg.UserName,
|
||||
Password = Configuration.conf.mQConnectionCfg.Password,
|
||||
Port = Configuration.conf.mQConnectionCfg.Port,
|
||||
ClientProvidedName = Configuration.conf.mQConnectionCfg.ClientProvidedName,
|
||||
HostName = Configurations.conf.mQConnectionCfg.HostName,
|
||||
VirtualHost = Configurations.conf.mQConnectionCfg.VirtualHost,
|
||||
UserName = Configurations.conf.mQConnectionCfg.UserName,
|
||||
Password = Configurations.conf.mQConnectionCfg.Password,
|
||||
Port = Configurations.conf.mQConnectionCfg.Port,
|
||||
ClientProvidedName = Configurations.conf.mQConnectionCfg.ClientProvidedName,
|
||||
RequestedHeartbeat = TimeSpan.FromSeconds(5)
|
||||
};
|
||||
}
|
||||
@@ -98,27 +98,27 @@ namespace ARI.EAP.HOST.MQ
|
||||
}
|
||||
TryConnect();
|
||||
Channel = conn.CreateModel();
|
||||
Channel.ExchangeDeclare(Configuration.conf.mQConnectionCfg.Exchange, ExchangeType.Direct, durable: true);
|
||||
Channel.ExchangeDeclare(Configuration.conf.mQConnectionCfg.Exchange_RTDB, ExchangeType.Direct, durable: true);
|
||||
Channel.ExchangeDeclare(Configurations.conf.mQConnectionCfg.Exchange, ExchangeType.Direct, durable: true);
|
||||
Channel.ExchangeDeclare(Configurations.conf.mQConnectionCfg.Exchange_RTDB, ExchangeType.Direct, durable: true);
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments.Add("x-dead-letter-exchange", Configuration.conf.mQConnectionCfg.Exchange_Name_Dle);
|
||||
arguments.Add("x-dead-letter-routing-key", Configuration.conf.mQConnectionCfg.Dead_Letter_RoutingKey);
|
||||
Channel.QueueDeclare(Configuration.conf.mQConnectionCfg.EAP_Request_Queue, true, false, false, arguments);
|
||||
Channel.QueueBind(Configuration.conf.mQConnectionCfg.EAP_Request_Queue, Configuration.conf.mQConnectionCfg.Exchange, Configuration.conf.mQConnectionCfg.EAP_Request_Queue_RoutingKey);
|
||||
Channel.QueueDeclare(Configuration.conf.mQConnectionCfg.EAP_Response_Queue, true, false, false, arguments);
|
||||
Channel.QueueBind(Configuration.conf.mQConnectionCfg.EAP_Response_Queue, Configuration.conf.mQConnectionCfg.Exchange, Configuration.conf.mQConnectionCfg.EAP_Response_Queue_RoutingKey);
|
||||
arguments.Add("x-dead-letter-exchange", Configurations.conf.mQConnectionCfg.Exchange_Name_Dle);
|
||||
arguments.Add("x-dead-letter-routing-key", Configurations.conf.mQConnectionCfg.Dead_Letter_RoutingKey);
|
||||
Channel.QueueDeclare(Configurations.conf.mQConnectionCfg.EAP_Request_Queue, true, false, false, arguments);
|
||||
Channel.QueueBind(Configurations.conf.mQConnectionCfg.EAP_Request_Queue, Configurations.conf.mQConnectionCfg.Exchange, Configurations.conf.mQConnectionCfg.EAP_Request_Queue_RoutingKey);
|
||||
Channel.QueueDeclare(Configurations.conf.mQConnectionCfg.EAP_Response_Queue, true, false, false, arguments);
|
||||
Channel.QueueBind(Configurations.conf.mQConnectionCfg.EAP_Response_Queue, Configurations.conf.mQConnectionCfg.Exchange, Configurations.conf.mQConnectionCfg.EAP_Response_Queue_RoutingKey);
|
||||
consumer = new EventingBasicConsumer(Channel);
|
||||
consumer.Received += MESResponse;
|
||||
Channel.BasicConsume(Configuration.conf.mQConnectionCfg.EAP_Response_Queue, true, consumer);
|
||||
Channel.QueueDeclare(Configuration.conf.mQConnectionCfg.MES_Request_Queue, true, false, false, arguments);
|
||||
Channel.QueueBind(Configuration.conf.mQConnectionCfg.MES_Request_Queue, Configuration.conf.mQConnectionCfg.Exchange, Configuration.conf.mQConnectionCfg.MES_Request_Queue_RoutingKey);
|
||||
Channel.QueueDeclare(Configuration.conf.mQConnectionCfg.MES_Response_Queue, true, false, false, arguments);
|
||||
Channel.QueueBind(Configuration.conf.mQConnectionCfg.MES_Response_Queue, Configuration.conf.mQConnectionCfg.Exchange, Configuration.conf.mQConnectionCfg.MES_Response_Queue_RoutingKey);
|
||||
Channel.QueueDeclare(Configuration.conf.mQConnectionCfg.EAP_Request_Queue_RTDB, true, false, false, arguments);
|
||||
Channel.QueueBind(Configuration.conf.mQConnectionCfg.EAP_Request_Queue_RTDB, Configuration.conf.mQConnectionCfg.Exchange_RTDB,"");
|
||||
Channel.BasicConsume(Configurations.conf.mQConnectionCfg.EAP_Response_Queue, true, consumer);
|
||||
Channel.QueueDeclare(Configurations.conf.mQConnectionCfg.MES_Request_Queue, true, false, false, arguments);
|
||||
Channel.QueueBind(Configurations.conf.mQConnectionCfg.MES_Request_Queue, Configurations.conf.mQConnectionCfg.Exchange, Configurations.conf.mQConnectionCfg.MES_Request_Queue_RoutingKey);
|
||||
Channel.QueueDeclare(Configurations.conf.mQConnectionCfg.MES_Response_Queue, true, false, false, arguments);
|
||||
Channel.QueueBind(Configurations.conf.mQConnectionCfg.MES_Response_Queue, Configurations.conf.mQConnectionCfg.Exchange, Configurations.conf.mQConnectionCfg.MES_Response_Queue_RoutingKey);
|
||||
Channel.QueueDeclare(Configurations.conf.mQConnectionCfg.EAP_Request_Queue_RTDB, true, false, false, arguments);
|
||||
Channel.QueueBind(Configurations.conf.mQConnectionCfg.EAP_Request_Queue_RTDB, Configurations.conf.mQConnectionCfg.Exchange_RTDB,"");
|
||||
consumer2 = new EventingBasicConsumer(Channel);
|
||||
consumer2.Received += MESRequest;
|
||||
Channel.BasicConsume(Configuration.conf.mQConnectionCfg.MES_Request_Queue, true, consumer2);
|
||||
Channel.BasicConsume(Configurations.conf.mQConnectionCfg.MES_Request_Queue, true, consumer2);
|
||||
EquipmentStatus.MQstate = ConnectState.connected;
|
||||
return true;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ namespace ARI.EAP.HOST.MQ
|
||||
var body = ea.Body.ToArray();
|
||||
var message = Encoding.UTF8.GetString(body);
|
||||
MQMessage mQMessage = JsonConvert.DeserializeObject<MQMessage>(message);
|
||||
Global.MF.addMQlog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "MQ=>H", LoggerService.Receive, mQMessage.header.messageName, mQMessage.header.transactionId);
|
||||
Global.MF.addMQlog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),LoggerService.Receive, mQMessage.header.messageName, SECSUtil.ToJson<MQMessage>(mQMessage));
|
||||
LoggerService.MQLogger.Info(mQMessage.header.transactionId + " MQ Receive:" + SECSUtil.ToJson<MQMessage>(mQMessage) + System.Environment.NewLine + ".");
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace ARI.EAP.HOST.MQ
|
||||
var body = ea.Body.ToArray();
|
||||
var message = Encoding.UTF8.GetString(body);
|
||||
MQMessage mesMessage = JsonConvert.DeserializeObject<MQMessage>(message);
|
||||
Global.MF.addMQlog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "MQ=>H", LoggerService.Receive, mesMessage.header.messageName, mesMessage.header.transactionId);
|
||||
Global.MF.addMQlog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), LoggerService.Receive, mesMessage.header.messageName, SECSUtil.ToJson<MQMessage>(mesMessage));
|
||||
LoggerService.MQLogger.Info(mesMessage.header.transactionId + " MQ Receive:" + SECSUtil.ToJson<MQMessage>(mesMessage) + System.Environment.NewLine + ".");
|
||||
Task.Run(() => MESRequestHandler.Execute(mesMessage));
|
||||
}
|
||||
@@ -204,8 +204,8 @@ namespace ARI.EAP.HOST.MQ
|
||||
{
|
||||
if (IsConnected)
|
||||
{
|
||||
Channel.BasicPublish(Configuration.conf.mQConnectionCfg.Exchange, Configuration.conf.mQConnectionCfg.EAP_Request_Queue_RoutingKey, null, data);
|
||||
Global.MF.addMQlog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "H=>MQ", LoggerService.Send, message.header.messageName, message.header.transactionId);
|
||||
Channel.BasicPublish(Configurations.conf.mQConnectionCfg.Exchange, Configurations.conf.mQConnectionCfg.EAP_Request_Queue_RoutingKey, null, data);
|
||||
Global.MF.addMQlog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), LoggerService.Send, message.header.messageName, text);
|
||||
LoggerService.MQLogger.Info(message.header.transactionId + " MQ Send:" + text + System.Environment.NewLine + ".");
|
||||
}
|
||||
else
|
||||
@@ -229,8 +229,8 @@ namespace ARI.EAP.HOST.MQ
|
||||
{
|
||||
if (IsConnected)
|
||||
{
|
||||
Channel.BasicPublish(Configuration.conf.mQConnectionCfg.Exchange, Configuration.conf.mQConnectionCfg.MES_Response_Queue_RoutingKey, null, data);
|
||||
Global.MF.addMQlog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "H=>MQ", LoggerService.Send, message.header.messageName, message.header.transactionId);
|
||||
Channel.BasicPublish(Configurations.conf.mQConnectionCfg.Exchange, Configurations.conf.mQConnectionCfg.MES_Response_Queue_RoutingKey, null, data);
|
||||
Global.MF.addMQlog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), LoggerService.Send, message.header.messageName, text);
|
||||
LoggerService.MQLogger.Info(message.header.transactionId + " MQ Send:" + text + System.Environment.NewLine + ".");
|
||||
}
|
||||
else
|
||||
@@ -254,7 +254,7 @@ namespace ARI.EAP.HOST.MQ
|
||||
{
|
||||
if (IsConnected)
|
||||
{
|
||||
Channel.BasicPublish(Configuration.conf.mQConnectionCfg.Exchange_RTDB, "", null, data);
|
||||
Channel.BasicPublish(Configurations.conf.mQConnectionCfg.Exchange_RTDB, "", null, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user