You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 line
1.7 KiB

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