|
|
|
@ -58,21 +58,26 @@ namespace Myshipping.Core.MQ
|
|
|
|
|
|
|
|
|
|
ConnectionFactory factory = new ConnectionFactory();
|
|
|
|
|
var repoSysCfg = _serviceScope.ServiceProvider.GetService<SqlSugarRepository<SysConfig>>();
|
|
|
|
|
var mqUrl = repoSysCfg.FirstOrDefault(x => x.Code == "CompanyUserChangeMqUrl").Value;
|
|
|
|
|
_logger.LogInformation($"准备连接公司用户同步消息队列:{mqUrl}");
|
|
|
|
|
factory.Uri = new Uri(mqUrl);
|
|
|
|
|
mqConn = factory.CreateConnection("客户订舱平台客户端");
|
|
|
|
|
|
|
|
|
|
model = mqConn.CreateModel();
|
|
|
|
|
model.ExchangeDeclare(ExchangeName, ExchangeType.Fanout);
|
|
|
|
|
model.QueueDeclare(QueueName, false, false, true, null);
|
|
|
|
|
model.QueueBind(QueueName, ExchangeName, "", null);
|
|
|
|
|
|
|
|
|
|
var consumer = new EventingBasicConsumer(model);
|
|
|
|
|
consumer.Received += Consumer_Received;
|
|
|
|
|
model.BasicConsume(QueueName, true, consumer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mqUrl = repoSysCfg.FirstOrDefault(x => x.Code == "CompanyUserChangeMqUrl")?.Value;
|
|
|
|
|
if (string.IsNullOrEmpty(mqUrl))
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError($"接收公司、员工变动消息推送所需MQUrl未配置");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation($"准备连接公司用户同步消息队列:{mqUrl}");
|
|
|
|
|
factory.Uri = new Uri(mqUrl);
|
|
|
|
|
mqConn = factory.CreateConnection("客户订舱平台客户端");
|
|
|
|
|
|
|
|
|
|
model = mqConn.CreateModel();
|
|
|
|
|
model.ExchangeDeclare(ExchangeName, ExchangeType.Fanout);
|
|
|
|
|
model.QueueDeclare(QueueName, false, false, true, null);
|
|
|
|
|
model.QueueBind(QueueName, ExchangeName, "", null);
|
|
|
|
|
|
|
|
|
|
var consumer = new EventingBasicConsumer(model);
|
|
|
|
|
consumer.Received += Consumer_Received;
|
|
|
|
|
model.BasicConsume(QueueName, true, consumer);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|