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 line
1.1 KiB

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