mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-11 01:10:29 +08:00
fix: remove _zh_CN suffix from messages basename, add graceful shutdown drain
- messages basename: drop _zh_CN suffix (Spring auto-appends locale), eliminating repeated ResourceBundle WARN during every request - OrganizationServer: add @EventListener(ContextClosedEvent) with 30s drain delay to let in-flight requests complete before bean destruction begins
This commit is contained in:
+17
-1
@@ -21,6 +21,9 @@ import org.springframework.cloud.netflix.hystrix.EnableHystrix;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.context.event.ContextClosedEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
@@ -63,7 +66,20 @@ implements WebApplicationInitializer {
|
||||
protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
|
||||
if (HttpMethod.DELETE == httpMethod) {
|
||||
return new VMSHttpEntityEnclosingRequestBase(uri);
|
||||
}
|
||||
@EventListener
|
||||
@Order(0)
|
||||
public void onShutdown(ContextClosedEvent event) {
|
||||
log.info("Graceful shutdown: draining in-flight requests ({}ms)...", SHUTDOWN_DRAIN_MS);
|
||||
try {
|
||||
Thread.sleep(SHUTDOWN_DRAIN_MS);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
log.info("Graceful shutdown: drain complete");
|
||||
}
|
||||
|
||||
private static final long SHUTDOWN_DRAIN_MS = 30_000L;
|
||||
}
|
||||
return super.createHttpUriRequest(httpMethod, uri);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user