Skip to content

Shutdown MessageListenerContainer after max retries exceeded #2259

Answered by garyrussell
m-kay asked this question in Q&A
Discussion options

You must be logged in to vote

Simply add a custom recoverer to a subclass of the DefaultErrorHandler that calls the CommonContainerStoppingErrorHandler when it is called after the retries are exhausted. Something like this should work:

@Bean
CommonErrorHandler eh() {
	CommonContainerStoppingErrorHandler cseh = new CommonContainerStoppingErrorHandler();
	AtomicReference<Consumer<? ,?>> consumer2 = new AtomicReference<>();
	AtomicReference<MessageListenerContainer> container2 = new AtomicReference<>();

	return new DefaultErrorHandler((rec, ex) -> {
		cseh.handleRemaining(ex, Collections.singletonList(rec), consumer2.get(), container2.get());
	}, new FixedBackOff(1000L, 4)) {

		@Override
		public void handleRemaining(E…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@m-kay
Comment options

Answer selected by m-kay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants