40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
|
|
using System.Text;
|
||
|
|
|
||
|
|
namespace QYZH.InteractiveMagazine.WorkService.Consumers;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 自动铺码消费者
|
||
|
|
/// </summary>
|
||
|
|
public class AutoDotCodeConsumer : IQueueConsumer
|
||
|
|
{
|
||
|
|
private readonly ILogger<AutoDotCodeConsumer> _logger;
|
||
|
|
|
||
|
|
public AutoDotCodeConsumer(ILogger<AutoDotCodeConsumer> logger)
|
||
|
|
{
|
||
|
|
_logger = logger;
|
||
|
|
}
|
||
|
|
|
||
|
|
public string Exchange => "ex.journal";
|
||
|
|
|
||
|
|
public string QueueName => "mq.journal.dotcode.auto";
|
||
|
|
|
||
|
|
public string RoutingKey => "rk.journal.dotcode.auto";
|
||
|
|
|
||
|
|
public async Task HandleAsync(byte[] message)
|
||
|
|
{
|
||
|
|
var body = Encoding.UTF8.GetString(message);
|
||
|
|
_logger.LogInformation("收到自动铺码消息: {Message}", body);
|
||
|
|
|
||
|
|
// TODO: 在此编写具体的铺码处理逻辑
|
||
|
|
|
||
|
|
await Task.CompletedTask;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Task OnErrorAsync(byte[] message, Exception exception)
|
||
|
|
{
|
||
|
|
var body = Encoding.UTF8.GetString(message);
|
||
|
|
_logger.LogError(exception, "处理自动铺码消息失败: {Message}", body);
|
||
|
|
return Task.CompletedTask;
|
||
|
|
}
|
||
|
|
}
|