Skip to content

Commit e7e77b9

Browse files
authored
Clarify retries in KSIQS docs
* Clarify how `KafkaStreamsInteractiveQueryService` retries works in the docs
1 parent f2e77e6 commit e7e77b9

File tree

1 file changed

+22
-0
lines changed
  • spring-kafka-docs/src/main/antora/modules/ROOT/pages

1 file changed

+22
-0
lines changed

spring-kafka-docs/src/main/antora/modules/ROOT/pages/streams.adoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,28 @@ When calling this method, the user can specifially ask for the proper state stor
365365

366366
NOTE: `KafkaStreamsInteractiveQueryService` API in Spring for Apache Kafka only supports providing access to local key-value stores at the moment.
367367

368+
==== Retrying State Store Retrieval
369+
370+
When trying to retrieve the state store using the `KafkaStreamsInteractiveQueryService`, there is a chance that the state store might not be found for various reasons.
371+
If those reasons are transitory, `KafkaStreamsInteractiveQueryService` provides an option to retry the retrieval of the state store by allowing to inject a custom `RetryTemplate`.
372+
By default, the `RetryTemmplate` that is used in `KafkaStreamsInteractiveQueryService` uses a maximum attempts of three with a fixed backoff of one second.
373+
374+
Here is how you can inject a custom `RetryTemmplate` into `KafkaStreamsInteractiveQueryService` with the maximum attempts of ten.
375+
376+
[source, java]
377+
----
378+
@Bean
379+
public KafkaStreamsInteractiveQueryService kafkaStreamsInteractiveQueryService(StreamsBuilderFactoryBean streamsBuilderFactoryBean) {
380+
final KafkaStreamsInteractiveQueryService kafkaStreamsInteractiveQueryService =
381+
new KafkaStreamsInteractiveQueryService(streamsBuilderFactoryBean);
382+
RetryTemplate retryTemplate = new RetryTemplate();
383+
retryTemplate.setBackOffPolicy(new FixedBackOffPolicy());
384+
RetryPolicy retryPolicy = new SimpleRetryPolicy(10);
385+
retryTemplate.setRetryPolicy(retryPolicy);
386+
kafkaStreamsInteractiveQueryService.setRetryTemplate(retryTemplate);
387+
return kafkaStreamsInteractiveQueryService;
388+
}
389+
----
368390

369391
[[kafka-streams-example]]
370392
== Kafka Streams Example

0 commit comments

Comments
 (0)