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.
 
 
 

42 regels
1.3 KiB

  1. using System;
  2. using DotNetCore.CAP.Messages;
  3. using Microsoft.AspNetCore.Builder;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.Logging;
  6. namespace Sample.RabbitMQ.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.UseRabbitMQ("192.168.2.120");
  17. x.UseDashboard();
  18. x.FailedRetryCount = 5;
  19. x.FailedThresholdCallback = failed =>
  20. {
  21. var logger = failed.ServiceProvider.GetService<ILogger<Startup>>();
  22. logger.LogError($@"A message of type {failed.MessageType} failed after executing {x.FailedRetryCount} several times,
  23. requiring manual troubleshooting. Message name: {failed.Message.GetName()}");
  24. };
  25. });
  26. services.AddControllers();
  27. }
  28. public void Configure(IApplicationBuilder app)
  29. {
  30. app.UseRouting();
  31. app.UseEndpoints(endpoints =>
  32. {
  33. endpoints.MapControllers();
  34. });
  35. }
  36. }
  37. }