Class KafkaStreamsInteractiveQueryService
java.lang.Object
org.springframework.kafka.streams.KafkaStreamsInteractiveQueryService
Provide a wrapper API around the interactive query stores in Kafka Streams.
Using this API, an application can gain access to a named state store in the
KafkaStreams
under consideration.- Since:
- 3.2
- Author:
- Soby Chacko
-
Constructor Summary
ConstructorDescriptionKafkaStreamsInteractiveQueryService
(StreamsBuilderFactoryBean streamsBuilderFactoryBean) Construct an instance for querying state stores from the KafkaStreams in theStreamsBuilderFactoryBean
. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.kafka.streams.state.HostInfo
Retrieve the currentHostInfo
where this Kafka Streams application is running on.<K> org.apache.kafka.streams.state.HostInfo
getKafkaStreamsApplicationHostInfo
(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer) Retrieve theHostInfo
where the provided store and key are hosted on.<T> T
retrieveQueryableStore
(String storeName, org.apache.kafka.streams.state.QueryableStoreType<T> storeType) Retrieve and return a queryable store by name created in the application.void
setRetryTemplate
(org.springframework.retry.support.RetryTemplate retryTemplate) CustomRetryTemplate
provided by the end users.
-
Constructor Details
-
KafkaStreamsInteractiveQueryService
Construct an instance for querying state stores from the KafkaStreams in theStreamsBuilderFactoryBean
.- Parameters:
streamsBuilderFactoryBean
-StreamsBuilderFactoryBean
forKafkaStreams
.
-
-
Method Details
-
setRetryTemplate
public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate) CustomRetryTemplate
provided by the end users.- Parameters:
retryTemplate
-RetryTemplate
-
retrieveQueryableStore
public <T> T retrieveQueryableStore(String storeName, org.apache.kafka.streams.state.QueryableStoreType<T> storeType) Retrieve and return a queryable store by name created in the application.- Type Parameters:
T
- generic type for the queryable store- Parameters:
storeName
- name of the queryable storestoreType
- type of the queryable store- Returns:
- queryable store.
-
getCurrentKafkaStreamsApplicationHostInfo
@Nullable public org.apache.kafka.streams.state.HostInfo getCurrentKafkaStreamsApplicationHostInfo()Retrieve the currentHostInfo
where this Kafka Streams application is running on. This {link @HostInfo} is different from the Kafka `bootstrap.server` property, and is based on the Kafka Streams configuration property `application.server` where user-defined REST endpoints can be invoked per each Kafka Streams application instance. If this property - `application.server` - is not available from the end-user application, then null is returned.- Returns:
- the current
HostInfo
-
getKafkaStreamsApplicationHostInfo
public <K> org.apache.kafka.streams.state.HostInfo getKafkaStreamsApplicationHostInfo(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer) Retrieve theHostInfo
where the provided store and key are hosted on. This may not be the current host that is running the application. Kafka Streams will look through all the consumer instances under the same application id and retrieves the proper host. Note that the end user applications must provide `application.server` as a configuration property for all the application instances when calling this method. If this is not available, then null maybe returned.- Type Parameters:
K
- generic type for key- Parameters:
store
- store namekey
- key to look forserializer
-Serializer
for the key- Returns:
- the
HostInfo
where the key for the provided store is hosted currently
-