处理Spring Cloud Config远程刷新事件失败

时间:2019-06-27 21:06:07

标签: spring-cloud spring-cloud-config spring-cloud-gateway

我已经通过Kafka使用Spring Cloud Bus构建了一个集成的Spring Cloud Config Server,用于动态刷新属性。我还有一个Spring Cloud Gateway应用程序,它使用这些属性并动态刷新它们。

我正在努力解决的事情之一是,如果我(无意间)在Spring Gateway路由中更新了错误的属性(例如:public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(o => o.AddPolicy("ThePolicy", builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); })); //services.AddCors(c => //{ // c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin()); //}); ConfigureServicesModule<AviationIQ_Dev_Phase2Context>.Register(services, Configuration); services.Configure<FormOptions>(o => { o.ValueLengthLimit = int.MaxValue; o.MultipartBodyLengthLimit = int.MaxValue; o.MemoryBufferThreshold = int.MaxValue; }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } //app.UseHttpsRedirection(); //app.UseMvc(); ConfigureModule.Configure(app, env, Configuration); app.UseCors("ThePolicy"); } } ,这里的反斜杠是错误的)。 路由在Spring Cloud Gateway中中断,并出现诸如无法初始化bean spring.cloud.gateway.routes[0].predicates[0]=Path=/demo/{demoId\:[0-9]+}之类的错误,事情开始变得怪异。

两个问题:

  1. 是否可以忽略不良的配置刷新事件?可能会跳过配置错误的刷新事件。
  2. 如果可能,是否有办法甚至在将这些属性应用于Spring上下文之前就对其进行评估?

0 个答案:

没有答案