feat(templateDistributor, BLL): доделал распределение шаблонов. Сохраняет в БД + ставит задания роботам на обновление. MqService - может принимать список объектов для отправки, доработана кодировка отправки сообщений.
This commit is contained in:
@@ -5,6 +5,8 @@ using PARR.BLL.Services.Interfaces;
|
||||
using RabbitMQ.Client;
|
||||
using RabbitMQ.Client.Events;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace PARR.BLL.Services.Implementations
|
||||
{
|
||||
@@ -17,6 +19,11 @@ namespace PARR.BLL.Services.Implementations
|
||||
|
||||
// реализация для RabbitMQ.Client 7.1.2
|
||||
|
||||
private static readonly JsonSerializerOptions jsonOptions = new JsonSerializerOptions
|
||||
{
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||
};
|
||||
|
||||
public MqServiceV2(ILogger<MqServiceV2> logger)
|
||||
{
|
||||
this.logger = logger;
|
||||
@@ -108,6 +115,12 @@ namespace PARR.BLL.Services.Implementations
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<MqSendResult> SendAsync(IMqSettings mqSettings, List<object> msgObjectList)
|
||||
{
|
||||
var msgStringList = msgObjectList.Select(t => JsonSerializer.Serialize(t, jsonOptions)).ToArray();
|
||||
|
||||
return await SendAsync(mqSettings, msgStringList);
|
||||
}
|
||||
|
||||
public async Task<MqSendResult> SendAsync(IMqSettings mqSettings, string[] msgList)
|
||||
{
|
||||
@@ -136,7 +149,8 @@ namespace PARR.BLL.Services.Implementations
|
||||
props.DeliveryMode = DeliveryModes.Persistent;
|
||||
//время жизни, мс
|
||||
//props.Expiration = "60000";
|
||||
props.ContentType = "text/plain";//"application/json";
|
||||
//props.ContentType = "text/plain";//"application/json";
|
||||
props.ContentType = "text/plain; charset=utf-8";//"application/json";
|
||||
|
||||
channel.BasicReturnAsync += async (sender, ea) =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user