0
votes

I am wondering if there is a way to enable Stateful RetryTemplate using spring-cloud-stream-binder-kafka.

I noticed that there is a constructor

RetryingMessageListenerAdapter(MessageListener<K, V> messageListener, RetryTemplate retryTemplate, RecoveryCallback<? extends Object> recoveryCallback, boolean stateful)

Debugging through this code, I noticed that boolean value false is passed into stateful parameter using spring-cloud-stream-binder-kafka.

Related links: KafkaMessageDrivenChannelAdapter.java, RetryingMessageListenerAdapter.java

I have a few questions regarding this topic.

  1. Is there a way to set RetryingMessageListenerAdapter's member stateful as true through application.yml or ListenerContainerCustomizer?
  2. Is there a way to disable RetryTemplate using spring-cloud-stream-binder-kafka? I think the closest I found was to override max-attempts to 1 in my @StreamRetryTemplate.
  3. If I am using SeekToCurrentErrorHandler provided by spring-kafka, is there any benefit or reason why I should set stateful as true since SeekToCurrentErrorHandler is already a stateful error handling mechanism?

Please let me know.

1

1 Answers

1
votes

Stateful retry is no longer needed now that the SeekToCurrentErrorHandler has retry and backoff capabilities.

Yes, to disable retry in the binder, set maxAttempts=1 and configure the STCEH appropriately.