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.

Startup.cs 1.4 KiB

7 years ago
7 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.Extensions.Configuration;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.Logging;
  6. namespace Sample.Kafka.SqlServer
  7. {
  8. public class Startup
  9. {
  10. public void ConfigureServices(IServiceCollection services)
  11. {
  12. services.AddDbContext<AppDbContext>();
  13. services.AddCap(x =>
  14. {
  15. x.UseEntityFramework<AppDbContext>();
  16. x.UseKafka("192.168.2.227:9091,192.168.2.227:9092,192.168.2.222:9092");
  17. x.UseDashboard();
  18. x.UseDiscovery(d =>
  19. {
  20. d.DiscoveryServerHostName = "localhost";
  21. d.DiscoveryServerProt = 8500;
  22. d.CurrentNodeHostName = "localhost";
  23. d.CurrentNodePort = 5820;
  24. d.NodeName = "CAP 2号节点";
  25. });
  26. });
  27. services.AddSession();
  28. services.AddMvc();
  29. }
  30. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  31. {
  32. loggerFactory.AddConsole();
  33. loggerFactory.AddDebug();
  34. app.UseSession();
  35. app.UseMvc();
  36. app.UseCap();
  37. app.UseCapDashboard();
  38. }
  39. }
  40. }