Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

44 рядки
1.8 KiB

  1. using JT808.Protocol;
  2. using JT808.Gateway.Kafka;
  3. using JT808.Gateway.ReplyMessage;
  4. using JT808.Gateway.SessionNotice;
  5. using Microsoft.Extensions.Configuration;
  6. using Microsoft.Extensions.DependencyInjection;
  7. using Microsoft.Extensions.Hosting;
  8. using Microsoft.Extensions.Logging;
  9. using System;
  10. using System.Threading.Tasks;
  11. using JT808.Gateway.SimpleQueueService.Impl;
  12. namespace JT808.Gateway.SimpleQueueService
  13. {
  14. class Program
  15. {
  16. static async Task Main(string[] args)
  17. {
  18. var hostBuilder = new HostBuilder()
  19. .ConfigureAppConfiguration((hostContext, config) => {
  20. config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory);
  21. config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
  22. })
  23. .ConfigureLogging((hostContext, configLogging) => {
  24. configLogging.AddConsole();
  25. configLogging.SetMinimumLevel(LogLevel.Trace);
  26. })
  27. .ConfigureServices((hostContext, services) => {
  28. services.AddSingleton<ILoggerFactory, LoggerFactory>();
  29. services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
  30. services.AddJT808Configure()
  31. .AddClientKafka()
  32. .AddMsgConsumer(hostContext.Configuration)
  33. .AddMsgReplyProducer(hostContext.Configuration)
  34. .AddSessionConsumer(hostContext.Configuration)
  35. .AddReplyMessage<JT808QueueReplyMessageHandlerImpl>()
  36. .AddSessionNotice<JT808SessionNoticeServiceImpl>();
  37. });
  38. await hostBuilder.RunConsoleAsync();
  39. }
  40. }
  41. }