Skip to content

Commit

Permalink
Clarify retries in KSIQS docs
Browse files Browse the repository at this point in the history
* Clarify how `KafkaStreamsInteractiveQueryService` retries works in the docs
  • Loading branch information
sobychacko authored Feb 13, 2024
1 parent f2e77e6 commit e7e77b9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions spring-kafka-docs/src/main/antora/modules/ROOT/pages/streams.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,28 @@ When calling this method, the user can specifially ask for the proper state stor

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

==== Retrying State Store Retrieval

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.
If those reasons are transitory, `KafkaStreamsInteractiveQueryService` provides an option to retry the retrieval of the state store by allowing to inject a custom `RetryTemplate`.
By default, the `RetryTemmplate` that is used in `KafkaStreamsInteractiveQueryService` uses a maximum attempts of three with a fixed backoff of one second.

This comment has been minimized.

Copy link
@frosiere

frosiere Feb 20, 2024

Contributor

Typo in RetryTemmplate. Same on the next line.


Here is how you can inject a custom `RetryTemmplate` into `KafkaStreamsInteractiveQueryService` with the maximum attempts of ten.

[source, java]
----
@Bean
public KafkaStreamsInteractiveQueryService kafkaStreamsInteractiveQueryService(StreamsBuilderFactoryBean streamsBuilderFactoryBean) {
final KafkaStreamsInteractiveQueryService kafkaStreamsInteractiveQueryService =
new KafkaStreamsInteractiveQueryService(streamsBuilderFactoryBean);
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setBackOffPolicy(new FixedBackOffPolicy());
RetryPolicy retryPolicy = new SimpleRetryPolicy(10);
retryTemplate.setRetryPolicy(retryPolicy);
kafkaStreamsInteractiveQueryService.setRetryTemplate(retryTemplate);
return kafkaStreamsInteractiveQueryService;
}
----

[[kafka-streams-example]]
== Kafka Streams Example
Expand Down

0 comments on commit e7e77b9

Please sign in to comment.