feat(bll, all): обновлена библиотека RabbitMq.Client до версии 7.1.2. Обновлен MqServiceV2. В IMqSettings добавлен параметр PrefetchCount - макс кол-во одновременных обработок очередей. Обновлены связанные проекты под новый MqService. В проектах Aihit, SyncTemplate, SyncSchedule установлен параметр в конфиг PrefetchCount =100
This commit is contained in:
@@ -6,44 +6,45 @@ namespace PARR.MockData
|
||||
{
|
||||
internal class EsppDataImporter
|
||||
{
|
||||
public void Import() {
|
||||
var factory = new ConnectionFactory() { HostName = "10.99.253.216" };
|
||||
factory.UserName = "espp_templates_robot";
|
||||
factory.Password = "P@ssRwEsppTempl202";
|
||||
public void Import()
|
||||
{
|
||||
//var factory = new ConnectionFactory() { HostName = "10.99.253.216" };
|
||||
//factory.UserName = "espp_templates_robot";
|
||||
//factory.Password = "P@ssRwEsppTempl202";
|
||||
|
||||
string[] rows = EsppExport.data.Replace("\r", "").Split('\n');
|
||||
using (var connection = factory.CreateConnection())
|
||||
using (var channel = connection.CreateModel())
|
||||
{
|
||||
//https://www.rabbitmq.com/lazy-queues.html
|
||||
//Рекомендовано при работе порциями использовать ленивые очереди. сообщения не используют память
|
||||
//Формируем соответствующий аргумент
|
||||
Dictionary<String, Object> argums = new Dictionary<String, Object>();
|
||||
argums.Add("x-queue-mode", "lazy");
|
||||
//string[] rows = EsppExport.data.Replace("\r", "").Split('\n');
|
||||
//using (var connection = factory.CreateConnection())
|
||||
//using (var channel = connection.CreateModel())
|
||||
//{
|
||||
// //https://www.rabbitmq.com/lazy-queues.html
|
||||
// //Рекомендовано при работе порциями использовать ленивые очереди. сообщения не используют память
|
||||
// //Формируем соответствующий аргумент
|
||||
// Dictionary<String, Object> argums = new Dictionary<String, Object>();
|
||||
// argums.Add("x-queue-mode", "lazy");
|
||||
|
||||
//Объявляем очередь с которой будем работать. Если такой очереди ещё нет, то создатся. Если нет, нужно параметры типа durable должны совпадать иначе будет ошибка. В целом эти параметры можно посмотреть в админке RabbitMQ
|
||||
channel.QueueDeclare(queue: "parr-espp-templates",
|
||||
durable: true,//If you want to make sure your messages are persisted, you need to create a durable queue. To do this, simply set the durable flag to true when creating the queue.
|
||||
exclusive: false,
|
||||
autoDelete: false,
|
||||
arguments: argums);
|
||||
//перебираем строки и отправляем строки сообщениями
|
||||
for (int i = 0; i < rows.Count(); i++)
|
||||
{
|
||||
var body = Encoding.UTF8.GetBytes(rows[i]);
|
||||
IBasicProperties props = channel.CreateBasicProperties();
|
||||
//If you don’t mark your messages as persistent, then RabbitMQ will store them in memory. This is fine if you’re just playing around or building a prototype. But if you’re building a production system, then you need to make sure that your messages are persisted to disk so that they’re not lost if the server crashes.
|
||||
//Говорим менеджеру RabbitMq при получении хранить сообщения на диске
|
||||
props.DeliveryMode = 2;
|
||||
//время жизни в мс. на этапе отладки сделаем коротким чтобы не устраивать помойку
|
||||
props.Expiration = "60000";
|
||||
// //Объявляем очередь с которой будем работать. Если такой очереди ещё нет, то создатся. Если нет, нужно параметры типа durable должны совпадать иначе будет ошибка. В целом эти параметры можно посмотреть в админке RabbitMQ
|
||||
// channel.QueueDeclare(queue: "parr-espp-templates",
|
||||
// durable: true,//If you want to make sure your messages are persisted, you need to create a durable queue. To do this, simply set the durable flag to true when creating the queue.
|
||||
// exclusive: false,
|
||||
// autoDelete: false,
|
||||
// arguments: argums);
|
||||
// //перебираем строки и отправляем строки сообщениями
|
||||
// for (int i = 0; i < rows.Count(); i++)
|
||||
// {
|
||||
// var body = Encoding.UTF8.GetBytes(rows[i]);
|
||||
// IBasicProperties props = channel.CreateBasicProperties();
|
||||
// //If you don’t mark your messages as persistent, then RabbitMQ will store them in memory. This is fine if you’re just playing around or building a prototype. But if you’re building a production system, then you need to make sure that your messages are persisted to disk so that they’re not lost if the server crashes.
|
||||
// //Говорим менеджеру RabbitMq при получении хранить сообщения на диске
|
||||
// props.DeliveryMode = 2;
|
||||
// //время жизни в мс. на этапе отладки сделаем коротким чтобы не устраивать помойку
|
||||
// props.Expiration = "60000";
|
||||
|
||||
channel.BasicPublish(exchange: "",
|
||||
routingKey: "parr-espp-templates",//совпадает с именем очереди иначе не принимает
|
||||
basicProperties: props,
|
||||
body: body);
|
||||
}
|
||||
}
|
||||
// channel.BasicPublish(exchange: "",
|
||||
// routingKey: "parr-espp-templates",//совпадает с именем очереди иначе не принимает
|
||||
// basicProperties: props,
|
||||
// body: body);
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="RabbitMQ.Client" Version="6.5.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
|
||||
Reference in New Issue
Block a user