|
1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using System.Text.Encodings.Web;
- using System.Text.Unicode;
- using DotNetCore.CAP.Messages;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
-
- namespace Sample.RabbitMQ.SqlServer
- {
- public class Startup
- {
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddDbContext<AppDbContext>();
-
- services.AddCap(x =>
- {
- x.UseEntityFramework<AppDbContext>();
- x.UseRabbitMQ("");
- x.UseDashboard();
- x.FailedRetryCount = 5;
- x.FailedThresholdCallback = failed =>
- {
- var logger = failed.ServiceProvider.GetService<ILogger<Startup>>();
- logger.LogError($@"A message of type {failed.MessageType} failed after executing {x.FailedRetryCount} several times,
- requiring manual troubleshooting. Message name: {failed.Message.GetName()}");
- };
- x.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
- });
-
- services.AddControllers();
- }
-
- public void Configure(IApplicationBuilder app)
- {
- app.UseRouting();
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllers();
- });
- }
- }
- }
|