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.
 
 
 

38 lines
1.1 KiB

  1. using System;
  2. using Microsoft.AspNetCore.Builder;
  3. using Microsoft.AspNetCore.Hosting;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.Logging;
  6. namespace Sample.RabbitMQ.MySql
  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("localhost");
  17. x.UseDashboard();
  18. x.FailedRetryCount = 5;
  19. x.FailedThresholdCallback = (type, name, content) =>
  20. {
  21. Console.WriteLine($@"A message of type {type} failed after executing {x.FailedRetryCount} several times, requiring manual troubleshooting. Message name: {name}, message body: {content}");
  22. };
  23. });
  24. services.AddMvc();
  25. }
  26. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  27. {
  28. app.UseMvc();
  29. app.UseCap();
  30. }
  31. }
  32. }