Sitemap
Javarevisited

A humble place to learn Java and Programming better.

Member-only story

Interviewer: How to Achieve Graceful Shutdown in Spring Boot

--

Photo by on

My articles are open to everyone; non-member readers can read theull article by clicking this link.

What is Graceful Shutdown?

Imagine you’re at a grand dinner party, and suddenly someone announces, “Everyone, leave immediately!” It would be chaos, right? Graceful shutdown is like ending that dinner party in an orderly manner, ensuring each guest can leave gracefully rather than being abruptly forced out.

In simple terms, graceful shutdown is about sending a “please stop” signal to an application process, ensuring that ongoing operations are unaffected until they are completed. It’s like telling the dinner guests, “Take your time, finish your meal, and then leave.”

When an application receives the shutdown signal, it performs the following steps:

  1. Stop Accepting New Requests: It ceases to accept new incoming requests, much like closing the doors to new guests at the dinner party.
  2. Allow Current Requests to Complete: Requests currently being processed are allowed to finish, just as guests are given time to finish their meals. For other internal tasks, such as scheduled jobs or message queue (MQ) consumption, the application ensures that ongoing tasks are completed and no new tasks are initiated.
Javarevisited
Javarevisited

Published in Javarevisited

A humble place to learn Java and Programming better.

Dylan Smith
Dylan Smith

Written by Dylan Smith

Software Engineer for a leading global e-commerce company. Dedicated to explaining every programming knowledge with interesting and simple examples.

Responses (2)