30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
|
|
using JiShe.CollectBus.Common.Models;
|
|||
|
|
using JiShe.CollectBus.Protocol.Contracts.Interfaces;
|
|||
|
|
using MassTransit;
|
|||
|
|
using Microsoft.Extensions.DependencyInjection;
|
|||
|
|
using Microsoft.Extensions.Logging;
|
|||
|
|
|
|||
|
|
namespace JiShe.CollectBus.MQ.Consumer
|
|||
|
|
{
|
|||
|
|
public class MessageReceivedHeartbeatConsumer(
|
|||
|
|
ILogger<MessageReceivedHeartbeatConsumer> logger,
|
|||
|
|
IServiceProvider serviceProvider)
|
|||
|
|
: IConsumer<MessageReceivedHeartbeatEvent>
|
|||
|
|
{
|
|||
|
|
public async Task Consume(ConsumeContext<MessageReceivedHeartbeatEvent> context)
|
|||
|
|
{
|
|||
|
|
logger.LogInformation("心跳消费队列开始处理");
|
|||
|
|
var protocolPlugin = serviceProvider.GetKeyedService<IProtocolPlugin>("Standard");
|
|||
|
|
if (protocolPlugin == null)
|
|||
|
|
{
|
|||
|
|
logger.LogError("【心跳消费队列开始处理】协议不存在!");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
await protocolPlugin.HeartbeatAsync(context.Message);
|
|||
|
|
logger.LogInformation("心跳消费队列完成处理");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|