Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/shutdown and spring integration orderly shutdown #5144

Open
srnm opened this issue Feb 13, 2016 · 3 comments
Open

/shutdown and spring integration orderly shutdown #5144

srnm opened this issue Feb 13, 2016 · 3 comments
Labels
type: enhancement A general enhancement

Comments

@srnm
Copy link

srnm commented Feb 13, 2016

The current implementation of the /shutdown endpoint does not delegate to SI's orderly shutdown mechanism when available.

Thanks!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 13, 2016
@wilkinsona
Copy link
Member

See also #4657

@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 15, 2016
@xak2000
Copy link
Contributor

xak2000 commented Dec 28, 2016

Also I should ask, how to properly shutdown spring-integration even without /shutdown endpoint? i.e. just from plain SIGTERM. Out of the box the container shutting down asap, not allowing any in-process handlers to complete. So any beans used by processing method are already destroyed when it completes (transactions cannot commit, jpa unit already closed etc).

For now I solved this problem by declaring custom taskScheduler bean, which spring-integration is using for poller's creation.

	@Bean
	public TaskScheduler taskScheduler() {
		ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
		scheduler.setPoolSize(10);
		scheduler.setWaitForTasksToCompleteOnShutdown(true);
		scheduler.setAwaitTerminationSeconds(20);
		return scheduler;
	}

The key part is setAwaitTerminationSeconds(20). It prevents container shutting down util TaskScheduler's in-flight tasks (spring-integration's pollers in this case) finish their work.

But I wonder if this is correct approach? Maybe when Spring destroys taskScheduler bean, some beans may already be destroyed?

I was very surprised that official spring-integration documentation has no any words about graceful shutdown the message flow (with the exception of the JMX). Isn't it the first question, that each developer asks himself when trying to use spring-integration for his needs?

This question is maybe offtopic for this issue, but maybe it makes you wonder about things that may have been overlooked otherwise.

@srnm
Copy link
Author

srnm commented Jan 22, 2017

One way to control shutdown order is via a "depends-on" declaration when defining the bean.

Another way may be to use parent/child ApplicationContexts.
However, setting up parent/child contexts appears to be a little complicated in Spring Boot.
It seems only to be used for servlet contexts...

More docs/guidance here would be appreciated.

@philwebb philwebb added this to the Icebox milestone Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants