Spring boot app when shutting down doesnt disallow new incoming connections but abruptly exitsProgrammatically shut down Spring Boot applicationSpring Boot - websocket controller problemsSpring boot post method is not workingWhy does spring boot application running on embedded tomcat shut downs automatically after 1-2 hours on ubuntu 14.04 aws VM?Spring Webflux Router Functions not being usedLogIn with spring security not workWhat causes Spring scheduler to execute before the application and servlet starts up?Springboot 2 app shuts down in openshift pod after startup..No errors. Works fine locally on windowsCould not fetch user details: ..springframework.security.oauth2.client.resource.UserRedirectRequiredExceptionhow to fix 'resource not found' when trying to download file in spring boot REST API?
Accidentally deleted the "/usr/share" folder
Besides the up and down quark, what other quarks are present in daily matter around us?
How can I support myself financially as a 17 year old with a loan?
Can't remove one character of space in my environment
Was there ever a Kickstart that took advantage of 68020+ instructions that would work on an A2000?
Type-check an expression
If Earth is tilted, why is Polaris always above the same spot?
Help to understand a simple example of clist in expl3
A non-technological, repeating, phenomenon in the sky, holding its position in the sky for hours
Reconstruct a matrix from its traces
Missed the connecting flight, separate tickets on same airline - who is responsible?
What happens to the Time Stone
Why is `abs()` implemented differently?
Was Unix ever a single-user OS?
What are the spoon bit of a spoon and fork bit of a fork called?
Alias to source .bashrc after it's been edited?
Can fracking help reduce CO2?
60s (or earlier) SF short story with FTL Travel using electron psychology aka addiclenendar technology
Do I have to make someone coauthor if he/she solves a problem in StackExchange, asked by myself, which is later used in my paper?
Can the 歳 counter be used for architecture, furniture etc to tell its age?
What happens to matryoshka Mordenkainen's Magnificent Mansions?
Selecting a secure PIN for building access
Airbnb - host wants to reduce rooms, can we get refund?
Moving the subject of the sentence into a dangling participle
Spring boot app when shutting down doesnt disallow new incoming connections but abruptly exits
Programmatically shut down Spring Boot applicationSpring Boot - websocket controller problemsSpring boot post method is not workingWhy does spring boot application running on embedded tomcat shut downs automatically after 1-2 hours on ubuntu 14.04 aws VM?Spring Webflux Router Functions not being usedLogIn with spring security not workWhat causes Spring scheduler to execute before the application and servlet starts up?Springboot 2 app shuts down in openshift pod after startup..No errors. Works fine locally on windowsCould not fetch user details: ..springframework.security.oauth2.client.resource.UserRedirectRequiredExceptionhow to fix 'resource not found' when trying to download file in spring boot REST API?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a spring boot app which creates a thread that monitors idle time before calling SpringApplication.exit() to terminate the app on being idle for a long time.. And i have a restcontroller class which serves web requests..
The issue is that even after SpringApplication.exit() is called, the controller seems to accept the incoming connections for a small window of time before the app itself exits. And this results in the client abruptly being terminated, when a new incoming connection is accepted by controller and then the earlier call to SpringApplication.exit() takes effect and makes the app exit.
//pseudo-code
@RestController
public class AppController
@PostMapping("/testproc")
public ExitStatus process(@RequestBody Job testJob)
logger.info("Job batch Id passed: ", testJob.batchId);
//do processing
if(shutdownFlag)
//report error to client
else
//do regular processing
@SpringBootApplication
public class MyApplication
public static void main(String[] args)
ctx = SpringApplication.run(MyApplication.class, args);
Thread shutdownThread = new Thread(new Runnable()
//check for some condition
if(shutdownFlag)
logger.info("Exiting");
SpringApplication.exit(ctx, () -> 0);
return;
);
shutdownThread.start();
logs generated:
2019-03-23 02:02:46.439 INFO 13484 --- [ Thread-10] c.i.e.newgenv1.svc.MyApplication : Exiting
2019-03-23 02:02:46.441 INFO 13484 --- [ Thread-10] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6660a289: startup date [Sat Mar 23 02:02:29 IST 2019]; root of context hierarchy
2019-03-23 02:02:46.509 INFO 13484 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2019-03-23 02:02:46.665 INFO 13484 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 156 ms
2019-03-23 02:02:47.559 INFO 13484 --- [nio-8081-exec-2] c.i.etl.newgenv1.svc.AppController : Job batch Id passed: 23
2019-03-23 02:02:53.828 INFO 13484 --- [ Thread-10] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
Pls note the lines logged.. The line "Exiting" generated by shutdown thread happens before Controller picks up a connection and prints batch id
I either need to stop the controller from picking up new connections or report an error code to the client during these times. But the issue is that controller picks up the connection but before it could report error, the app exits..
I even tried graceful shutdown logic outlined here: https://dzone.com/articles/graceful-shutdown-spring-boot-applications
but still it doesnt help..
java spring spring-boot model-view-controller
add a comment |
I have a spring boot app which creates a thread that monitors idle time before calling SpringApplication.exit() to terminate the app on being idle for a long time.. And i have a restcontroller class which serves web requests..
The issue is that even after SpringApplication.exit() is called, the controller seems to accept the incoming connections for a small window of time before the app itself exits. And this results in the client abruptly being terminated, when a new incoming connection is accepted by controller and then the earlier call to SpringApplication.exit() takes effect and makes the app exit.
//pseudo-code
@RestController
public class AppController
@PostMapping("/testproc")
public ExitStatus process(@RequestBody Job testJob)
logger.info("Job batch Id passed: ", testJob.batchId);
//do processing
if(shutdownFlag)
//report error to client
else
//do regular processing
@SpringBootApplication
public class MyApplication
public static void main(String[] args)
ctx = SpringApplication.run(MyApplication.class, args);
Thread shutdownThread = new Thread(new Runnable()
//check for some condition
if(shutdownFlag)
logger.info("Exiting");
SpringApplication.exit(ctx, () -> 0);
return;
);
shutdownThread.start();
logs generated:
2019-03-23 02:02:46.439 INFO 13484 --- [ Thread-10] c.i.e.newgenv1.svc.MyApplication : Exiting
2019-03-23 02:02:46.441 INFO 13484 --- [ Thread-10] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6660a289: startup date [Sat Mar 23 02:02:29 IST 2019]; root of context hierarchy
2019-03-23 02:02:46.509 INFO 13484 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2019-03-23 02:02:46.665 INFO 13484 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 156 ms
2019-03-23 02:02:47.559 INFO 13484 --- [nio-8081-exec-2] c.i.etl.newgenv1.svc.AppController : Job batch Id passed: 23
2019-03-23 02:02:53.828 INFO 13484 --- [ Thread-10] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
Pls note the lines logged.. The line "Exiting" generated by shutdown thread happens before Controller picks up a connection and prints batch id
I either need to stop the controller from picking up new connections or report an error code to the client during these times. But the issue is that controller picks up the connection but before it could report error, the app exits..
I even tried graceful shutdown logic outlined here: https://dzone.com/articles/graceful-shutdown-spring-boot-applications
but still it doesnt help..
java spring spring-boot model-view-controller
the lifecyle of the raw Thread you create cannot be managed by Spring automatically. If you want to have spring manage it, use springs ExecutorService, which should be automatically configured. see here for an example: dzone.com/articles/spring-and-threads-taskexecutor
– Gewure
Mar 23 at 2:32
I dont want to manage the lifecycle of the thread. I want to ensure that when SpringApplication.exit is called, no more new connections are accepted by the controller.. Thats the issue iam facing
– user3391196
Mar 23 at 16:28
yes, exactly. you don't want to manage the lifecyle yourself, which is why you want to use Springs ExecutorService, so Spring manages it for you
– Gewure
Mar 25 at 19:59
add a comment |
I have a spring boot app which creates a thread that monitors idle time before calling SpringApplication.exit() to terminate the app on being idle for a long time.. And i have a restcontroller class which serves web requests..
The issue is that even after SpringApplication.exit() is called, the controller seems to accept the incoming connections for a small window of time before the app itself exits. And this results in the client abruptly being terminated, when a new incoming connection is accepted by controller and then the earlier call to SpringApplication.exit() takes effect and makes the app exit.
//pseudo-code
@RestController
public class AppController
@PostMapping("/testproc")
public ExitStatus process(@RequestBody Job testJob)
logger.info("Job batch Id passed: ", testJob.batchId);
//do processing
if(shutdownFlag)
//report error to client
else
//do regular processing
@SpringBootApplication
public class MyApplication
public static void main(String[] args)
ctx = SpringApplication.run(MyApplication.class, args);
Thread shutdownThread = new Thread(new Runnable()
//check for some condition
if(shutdownFlag)
logger.info("Exiting");
SpringApplication.exit(ctx, () -> 0);
return;
);
shutdownThread.start();
logs generated:
2019-03-23 02:02:46.439 INFO 13484 --- [ Thread-10] c.i.e.newgenv1.svc.MyApplication : Exiting
2019-03-23 02:02:46.441 INFO 13484 --- [ Thread-10] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6660a289: startup date [Sat Mar 23 02:02:29 IST 2019]; root of context hierarchy
2019-03-23 02:02:46.509 INFO 13484 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2019-03-23 02:02:46.665 INFO 13484 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 156 ms
2019-03-23 02:02:47.559 INFO 13484 --- [nio-8081-exec-2] c.i.etl.newgenv1.svc.AppController : Job batch Id passed: 23
2019-03-23 02:02:53.828 INFO 13484 --- [ Thread-10] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
Pls note the lines logged.. The line "Exiting" generated by shutdown thread happens before Controller picks up a connection and prints batch id
I either need to stop the controller from picking up new connections or report an error code to the client during these times. But the issue is that controller picks up the connection but before it could report error, the app exits..
I even tried graceful shutdown logic outlined here: https://dzone.com/articles/graceful-shutdown-spring-boot-applications
but still it doesnt help..
java spring spring-boot model-view-controller
I have a spring boot app which creates a thread that monitors idle time before calling SpringApplication.exit() to terminate the app on being idle for a long time.. And i have a restcontroller class which serves web requests..
The issue is that even after SpringApplication.exit() is called, the controller seems to accept the incoming connections for a small window of time before the app itself exits. And this results in the client abruptly being terminated, when a new incoming connection is accepted by controller and then the earlier call to SpringApplication.exit() takes effect and makes the app exit.
//pseudo-code
@RestController
public class AppController
@PostMapping("/testproc")
public ExitStatus process(@RequestBody Job testJob)
logger.info("Job batch Id passed: ", testJob.batchId);
//do processing
if(shutdownFlag)
//report error to client
else
//do regular processing
@SpringBootApplication
public class MyApplication
public static void main(String[] args)
ctx = SpringApplication.run(MyApplication.class, args);
Thread shutdownThread = new Thread(new Runnable()
//check for some condition
if(shutdownFlag)
logger.info("Exiting");
SpringApplication.exit(ctx, () -> 0);
return;
);
shutdownThread.start();
logs generated:
2019-03-23 02:02:46.439 INFO 13484 --- [ Thread-10] c.i.e.newgenv1.svc.MyApplication : Exiting
2019-03-23 02:02:46.441 INFO 13484 --- [ Thread-10] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6660a289: startup date [Sat Mar 23 02:02:29 IST 2019]; root of context hierarchy
2019-03-23 02:02:46.509 INFO 13484 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2019-03-23 02:02:46.665 INFO 13484 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 156 ms
2019-03-23 02:02:47.559 INFO 13484 --- [nio-8081-exec-2] c.i.etl.newgenv1.svc.AppController : Job batch Id passed: 23
2019-03-23 02:02:53.828 INFO 13484 --- [ Thread-10] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
Pls note the lines logged.. The line "Exiting" generated by shutdown thread happens before Controller picks up a connection and prints batch id
I either need to stop the controller from picking up new connections or report an error code to the client during these times. But the issue is that controller picks up the connection but before it could report error, the app exits..
I even tried graceful shutdown logic outlined here: https://dzone.com/articles/graceful-shutdown-spring-boot-applications
but still it doesnt help..
java spring spring-boot model-view-controller
java spring spring-boot model-view-controller
edited Mar 23 at 2:12
Michael Petch
27.5k557106
27.5k557106
asked Mar 22 at 21:27
user3391196user3391196
66111
66111
the lifecyle of the raw Thread you create cannot be managed by Spring automatically. If you want to have spring manage it, use springs ExecutorService, which should be automatically configured. see here for an example: dzone.com/articles/spring-and-threads-taskexecutor
– Gewure
Mar 23 at 2:32
I dont want to manage the lifecycle of the thread. I want to ensure that when SpringApplication.exit is called, no more new connections are accepted by the controller.. Thats the issue iam facing
– user3391196
Mar 23 at 16:28
yes, exactly. you don't want to manage the lifecyle yourself, which is why you want to use Springs ExecutorService, so Spring manages it for you
– Gewure
Mar 25 at 19:59
add a comment |
the lifecyle of the raw Thread you create cannot be managed by Spring automatically. If you want to have spring manage it, use springs ExecutorService, which should be automatically configured. see here for an example: dzone.com/articles/spring-and-threads-taskexecutor
– Gewure
Mar 23 at 2:32
I dont want to manage the lifecycle of the thread. I want to ensure that when SpringApplication.exit is called, no more new connections are accepted by the controller.. Thats the issue iam facing
– user3391196
Mar 23 at 16:28
yes, exactly. you don't want to manage the lifecyle yourself, which is why you want to use Springs ExecutorService, so Spring manages it for you
– Gewure
Mar 25 at 19:59
the lifecyle of the raw Thread you create cannot be managed by Spring automatically. If you want to have spring manage it, use springs ExecutorService, which should be automatically configured. see here for an example: dzone.com/articles/spring-and-threads-taskexecutor
– Gewure
Mar 23 at 2:32
the lifecyle of the raw Thread you create cannot be managed by Spring automatically. If you want to have spring manage it, use springs ExecutorService, which should be automatically configured. see here for an example: dzone.com/articles/spring-and-threads-taskexecutor
– Gewure
Mar 23 at 2:32
I dont want to manage the lifecycle of the thread. I want to ensure that when SpringApplication.exit is called, no more new connections are accepted by the controller.. Thats the issue iam facing
– user3391196
Mar 23 at 16:28
I dont want to manage the lifecycle of the thread. I want to ensure that when SpringApplication.exit is called, no more new connections are accepted by the controller.. Thats the issue iam facing
– user3391196
Mar 23 at 16:28
yes, exactly. you don't want to manage the lifecyle yourself, which is why you want to use Springs ExecutorService, so Spring manages it for you
– Gewure
Mar 25 at 19:59
yes, exactly. you don't want to manage the lifecyle yourself, which is why you want to use Springs ExecutorService, so Spring manages it for you
– Gewure
Mar 25 at 19:59
add a comment |
1 Answer
1
active
oldest
votes
You can add an interceptor which will check if shutdown is initiated. If not, the flow will continue it's normal execution else the requests should be dropped and proper response should be sent.
How do I intercept and how do I send the response when the process itself has exited ?
– user3391196
Mar 23 at 16:22
The Process has not fully exited thats why the controller's are still getting executed. So you can add an interceptor which will intercept all the request URLs (*) and in its "preHandle" check if "shutdownFlag" is set to true. If its true, then populate a proper error message and response code and throw an error to client.
– Rahul Vedpathak
Mar 25 at 7:32
In fact, iam doing the checking of shutdown flag and sending of error response inside the controller instead of a specific interceptor.. I detect the shutdown flag inside the controller and send it.. But the problem is, the process is running when the connection is accepted by the controller, but before the controller could send the response, the process exits.
– user3391196
Mar 25 at 8:52
nevertheless.. can you give me a sample code which i can try
– user3391196
Mar 25 at 8:58
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308016%2fspring-boot-app-when-shutting-down-doesnt-disallow-new-incoming-connections-but%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can add an interceptor which will check if shutdown is initiated. If not, the flow will continue it's normal execution else the requests should be dropped and proper response should be sent.
How do I intercept and how do I send the response when the process itself has exited ?
– user3391196
Mar 23 at 16:22
The Process has not fully exited thats why the controller's are still getting executed. So you can add an interceptor which will intercept all the request URLs (*) and in its "preHandle" check if "shutdownFlag" is set to true. If its true, then populate a proper error message and response code and throw an error to client.
– Rahul Vedpathak
Mar 25 at 7:32
In fact, iam doing the checking of shutdown flag and sending of error response inside the controller instead of a specific interceptor.. I detect the shutdown flag inside the controller and send it.. But the problem is, the process is running when the connection is accepted by the controller, but before the controller could send the response, the process exits.
– user3391196
Mar 25 at 8:52
nevertheless.. can you give me a sample code which i can try
– user3391196
Mar 25 at 8:58
add a comment |
You can add an interceptor which will check if shutdown is initiated. If not, the flow will continue it's normal execution else the requests should be dropped and proper response should be sent.
How do I intercept and how do I send the response when the process itself has exited ?
– user3391196
Mar 23 at 16:22
The Process has not fully exited thats why the controller's are still getting executed. So you can add an interceptor which will intercept all the request URLs (*) and in its "preHandle" check if "shutdownFlag" is set to true. If its true, then populate a proper error message and response code and throw an error to client.
– Rahul Vedpathak
Mar 25 at 7:32
In fact, iam doing the checking of shutdown flag and sending of error response inside the controller instead of a specific interceptor.. I detect the shutdown flag inside the controller and send it.. But the problem is, the process is running when the connection is accepted by the controller, but before the controller could send the response, the process exits.
– user3391196
Mar 25 at 8:52
nevertheless.. can you give me a sample code which i can try
– user3391196
Mar 25 at 8:58
add a comment |
You can add an interceptor which will check if shutdown is initiated. If not, the flow will continue it's normal execution else the requests should be dropped and proper response should be sent.
You can add an interceptor which will check if shutdown is initiated. If not, the flow will continue it's normal execution else the requests should be dropped and proper response should be sent.
answered Mar 22 at 22:11
Rahul VedpathakRahul Vedpathak
503413
503413
How do I intercept and how do I send the response when the process itself has exited ?
– user3391196
Mar 23 at 16:22
The Process has not fully exited thats why the controller's are still getting executed. So you can add an interceptor which will intercept all the request URLs (*) and in its "preHandle" check if "shutdownFlag" is set to true. If its true, then populate a proper error message and response code and throw an error to client.
– Rahul Vedpathak
Mar 25 at 7:32
In fact, iam doing the checking of shutdown flag and sending of error response inside the controller instead of a specific interceptor.. I detect the shutdown flag inside the controller and send it.. But the problem is, the process is running when the connection is accepted by the controller, but before the controller could send the response, the process exits.
– user3391196
Mar 25 at 8:52
nevertheless.. can you give me a sample code which i can try
– user3391196
Mar 25 at 8:58
add a comment |
How do I intercept and how do I send the response when the process itself has exited ?
– user3391196
Mar 23 at 16:22
The Process has not fully exited thats why the controller's are still getting executed. So you can add an interceptor which will intercept all the request URLs (*) and in its "preHandle" check if "shutdownFlag" is set to true. If its true, then populate a proper error message and response code and throw an error to client.
– Rahul Vedpathak
Mar 25 at 7:32
In fact, iam doing the checking of shutdown flag and sending of error response inside the controller instead of a specific interceptor.. I detect the shutdown flag inside the controller and send it.. But the problem is, the process is running when the connection is accepted by the controller, but before the controller could send the response, the process exits.
– user3391196
Mar 25 at 8:52
nevertheless.. can you give me a sample code which i can try
– user3391196
Mar 25 at 8:58
How do I intercept and how do I send the response when the process itself has exited ?
– user3391196
Mar 23 at 16:22
How do I intercept and how do I send the response when the process itself has exited ?
– user3391196
Mar 23 at 16:22
The Process has not fully exited thats why the controller's are still getting executed. So you can add an interceptor which will intercept all the request URLs (*) and in its "preHandle" check if "shutdownFlag" is set to true. If its true, then populate a proper error message and response code and throw an error to client.
– Rahul Vedpathak
Mar 25 at 7:32
The Process has not fully exited thats why the controller's are still getting executed. So you can add an interceptor which will intercept all the request URLs (*) and in its "preHandle" check if "shutdownFlag" is set to true. If its true, then populate a proper error message and response code and throw an error to client.
– Rahul Vedpathak
Mar 25 at 7:32
In fact, iam doing the checking of shutdown flag and sending of error response inside the controller instead of a specific interceptor.. I detect the shutdown flag inside the controller and send it.. But the problem is, the process is running when the connection is accepted by the controller, but before the controller could send the response, the process exits.
– user3391196
Mar 25 at 8:52
In fact, iam doing the checking of shutdown flag and sending of error response inside the controller instead of a specific interceptor.. I detect the shutdown flag inside the controller and send it.. But the problem is, the process is running when the connection is accepted by the controller, but before the controller could send the response, the process exits.
– user3391196
Mar 25 at 8:52
nevertheless.. can you give me a sample code which i can try
– user3391196
Mar 25 at 8:58
nevertheless.. can you give me a sample code which i can try
– user3391196
Mar 25 at 8:58
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308016%2fspring-boot-app-when-shutting-down-doesnt-disallow-new-incoming-connections-but%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
the lifecyle of the raw Thread you create cannot be managed by Spring automatically. If you want to have spring manage it, use springs ExecutorService, which should be automatically configured. see here for an example: dzone.com/articles/spring-and-threads-taskexecutor
– Gewure
Mar 23 at 2:32
I dont want to manage the lifecycle of the thread. I want to ensure that when SpringApplication.exit is called, no more new connections are accepted by the controller.. Thats the issue iam facing
– user3391196
Mar 23 at 16:28
yes, exactly. you don't want to manage the lifecyle yourself, which is why you want to use Springs ExecutorService, so Spring manages it for you
– Gewure
Mar 25 at 19:59