Skip to content

Instantly share code, notes, and snippets.

@sidsamant
Created March 31, 2022 03:39
Show Gist options
  • Save sidsamant/6279d1747f463d082272c8b432544271 to your computer and use it in GitHub Desktop.
Save sidsamant/6279d1747f463d082272c8b432544271 to your computer and use it in GitHub Desktop.
@Bean
ListenerContainerWithDlqAndRetryCustomizer cust(KafkaTemplate<?, ?> template) {
return new ListenerContainerWithDlqAndRetryCustomizer() {
@Override
public void configure(AbstractMessageListenerContainer<?, ?> container, String destinationName,
String group,
@Nullable BiFunction<ConsumerRecord<?, ?>, Exception, TopicPartition> dlqDestinationResolver,
@Nullable BackOff backOff) {
if (destinationName.equals("topicWithLongTotalRetryConfig")) {
ConsumerRecordRecoverer dlpr = new DeadLetterPublishingRecoverer(template),
dlqDestinationResolver);
container.setCommonErrorHandler(new DefaultErrorHandler(dlpr, backOff));
}
}
@Override
public boolean retryAndDlqInBinding(String destinationName, String group) {
return !destinationName.contains("topicWithLongTotalRetryConfig");
}
};
}
@sidsamant
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment