Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

37 lines
1.3KB

  1. using HealthMonitor.Service.MessageQueue.Kafka;
  2. using Microsoft.EntityFrameworkCore.Diagnostics;
  3. using Microsoft.Extensions.Logging;
  4. using Newtonsoft.Json;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace HealthMonitor.Service.MessageQueue
  11. {
  12. public class MqProcessLogic
  13. {
  14. private readonly ILogger<MqProcessLogic> _logger;
  15. private readonly KafkaService _serviceKafka;
  16. public MqProcessLogic(ILogger<MqProcessLogic> logger, KafkaService serviceKafka)
  17. {
  18. _logger = logger;
  19. _serviceKafka = serviceKafka;
  20. }
  21. public async Task ProcessIMEIEventMessageAsync(string messagesId,string topicName,object eventData)
  22. {
  23. await _serviceKafka.PublishAsync(topicName, eventData);
  24. _logger.LogInformation($"推送消息 {messagesId} 内容:{JsonConvert.SerializeObject(eventData)}");
  25. }
  26. public async Task ProcessIMEIEventMessageAsync(string messagesId, string topicName, int dataTpe, object eventData)
  27. {
  28. await _serviceKafka.PublishAsync(topicName, dataTpe, eventData);
  29. _logger.LogInformation($"推送消息 {messagesId},数据类型:{dataTpe}, 内容:{JsonConvert.SerializeObject(eventData)}");
  30. }
  31. }
  32. }