Class InteractiveQueryService
java.lang.Object
org.springframework.cloud.stream.binder.kafka.streams.InteractiveQueryService
Services pertinent to the interactive query capabilities of Kafka Streams. This class
provides services such as querying for a particular store, which instance is hosting a
particular store etc. This is part of the public API of the kafka streams binder and
the users can inject this service in their applications to make use of it.
- Since:
- 2.1.0
- Author:
- Soby Chacko, Renwei Han, Serhii Siryi, Nico Pommerening, Chris Bono
-
Constructor Summary
ConstructorsConstructorDescriptionInteractiveQueryService(KafkaStreamsRegistry kafkaStreamsRegistry, KafkaStreamsBinderConfigurationProperties binderConfigurationProperties) Constructor for InteractiveQueryService. -
Method Summary
Modifier and TypeMethodDescriptionList<org.apache.kafka.streams.state.HostInfo>getAllHostsInfo(String store) Gets the list ofHostInfowhere the provided store is hosted on.org.apache.kafka.streams.state.HostInfoGets the currentHostInfothat the calling kafka streams application is running on.<K> org.apache.kafka.streams.state.HostInfogetHostInfo(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer) Gets theHostInfowhere the provided store and key are hosted on.<K> org.apache.kafka.streams.KafkaStreamsgetKafkaStreams(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer) Retrieves and returns theKafkaStreamsobject that is associated with the given combination of key and state store.<K> org.apache.kafka.streams.KeyQueryMetadatagetKeyQueryMetadata(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer) Retrieves and returns theKeyQueryMetadataassociated with the given combination of key and state store.<T> TgetQueryableStore(String storeName, org.apache.kafka.streams.state.QueryableStoreType<T> storeType) Retrieve and return a queryable store by name created in the application.
-
Constructor Details
-
InteractiveQueryService
public InteractiveQueryService(KafkaStreamsRegistry kafkaStreamsRegistry, KafkaStreamsBinderConfigurationProperties binderConfigurationProperties) Constructor for InteractiveQueryService.- Parameters:
kafkaStreamsRegistry- holdingKafkaStreamsRegistrybinderConfigurationProperties- kafka Streams binder configuration properties
-
-
Method Details
-
getQueryableStore
public <T> T getQueryableStore(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 queryable store- Parameters:
storeName- name of the queryable storestoreType- type of the queryable store- Returns:
- queryable store.
-
getCurrentHostInfo
public org.apache.kafka.streams.state.HostInfo getCurrentHostInfo()Gets the currentHostInfothat the calling kafka streams application is running on. Note that the end user applications must provide `applicaiton.server` as a configuration property when calling this method. If this is not available, then null is returned.- Returns:
- the current
HostInfo
-
getHostInfo
public <K> org.apache.kafka.streams.state.HostInfo getHostInfo(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer) Gets theHostInfowhere 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-Serializerfor the key- Returns:
- the
HostInfowhere the key for the provided store is hosted currently
-
getKeyQueryMetadata
public <K> org.apache.kafka.streams.KeyQueryMetadata getKeyQueryMetadata(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer) Retrieves and returns theKeyQueryMetadataassociated with the given combination of key and state store. If none found, it will return null.- Type Parameters:
K- generic type for key- Parameters:
store- store namekey- key to look forserializer-Serializerfor the key- Returns:
- the
KeyQueryMetadataif available, null otherwise.
-
getKafkaStreams
public <K> org.apache.kafka.streams.KafkaStreams getKafkaStreams(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer) Retrieves and returns theKafkaStreamsobject that is associated with the given combination of key and state store. If none found, it will return null.- Type Parameters:
K- generic type for key- Parameters:
store- store namekey- key to look forserializer-Serializerfor the key- Returns:
KafkaStreamsobject associated with this combination of store and key
-
getAllHostsInfo
Gets the list ofHostInfowhere the provided store is hosted on. It also can include current host info. Kafka Streams will look through all the consumer instances under the same application id and retrieves all hosts info. 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 an empty list will be returned.- Parameters:
store- store name- Returns:
- the list of
HostInfowhere provided store is hosted on
-