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.
 
 
 

40 lines
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.SqlServer
  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. }