您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

40 行
1.1 KiB

  1. using System;
  2. using DotNetCore.CAP.Messages;
  3. using Microsoft.AspNetCore.Builder;
  4. using Microsoft.Extensions.DependencyInjection;
  5. namespace Sample.RabbitMQ.MySql
  6. {
  7. public class Startup
  8. {
  9. public void ConfigureServices(IServiceCollection services)
  10. {
  11. services.AddDbContext<AppDbContext>();
  12. services.AddCap(x =>
  13. {
  14. x.UseEntityFramework<AppDbContext>();
  15. x.UseRabbitMQ("192.168.2.120");
  16. //x.UseDashboard();
  17. x.FailedRetryCount = 5;
  18. x.FailedThresholdCallback = (type, msg) =>
  19. {
  20. Console.WriteLine(
  21. $@"A message of type {type} failed after executing {x.FailedRetryCount} several times, requiring manual troubleshooting. Message name: {msg.GetName()}");
  22. };
  23. });
  24. services.AddControllers();
  25. }
  26. public void Configure(IApplicationBuilder app)
  27. {
  28. app.UseRouting();
  29. app.UseEndpoints(endpoints =>
  30. {
  31. endpoints.MapControllers();
  32. });
  33. }
  34. }
  35. }