Shutdown MessageListenerContainer after max retries exceeded #2259
-
Can we somehow configure the |
Beta Was this translation helpful? Give feedback.
Answered by
garyrussell
May 5, 2022
Replies: 1 comment 1 reply
-
Simply add a custom recoverer to a subclass of the @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(Exception thrownException, List<ConsumerRecord<?, ?>> records,
Consumer<?, ?> consumer, MessageListenerContainer container) {
consumer2.set(consumer);
container2.set(container);
super.handleRemaining(thrownException, records, consumer, container);
}
};
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
m-kay
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simply add a custom recoverer to a subclass of the
DefaultErrorHandler
that calls theCommonContainerStoppingErrorHandler
when it is called after the retries are exhausted. Something like this should work: