Class InteractiveQueryService

java.lang.Object
org.springframework.cloud.stream.binder.kafka.streams.InteractiveQueryService

public class InteractiveQueryService extends Object
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

    Constructors
    Constructor
    Description
    InteractiveQueryService(KafkaStreamsRegistry kafkaStreamsRegistry, KafkaStreamsBinderConfigurationProperties binderConfigurationProperties)
    Constructor for InteractiveQueryService.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<org.apache.kafka.streams.state.HostInfo>
    Gets the list of HostInfo where the provided store is hosted on.
    org.apache.kafka.streams.state.HostInfo
    Gets the current HostInfo that the calling kafka streams application is running on.
    <K> org.apache.kafka.streams.state.HostInfo
    getHostInfo(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer)
    Gets the HostInfo where the provided store and key are hosted on.
    <K> org.apache.kafka.streams.KafkaStreams
    getKafkaStreams(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer)
    Retrieves and returns the KafkaStreams object that is associated with the given combination of key and state store.
    <K> org.apache.kafka.streams.KeyQueryMetadata
    getKeyQueryMetadata(String store, K key, org.apache.kafka.common.serialization.Serializer<K> serializer)
    Retrieves and returns the KeyQueryMetadata associated with the given combination of key and state store.
    <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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • 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 store
      storeType - type of the queryable store
      Returns:
      queryable store.
    • getCurrentHostInfo

      public org.apache.kafka.streams.state.HostInfo getCurrentHostInfo()
      Gets the current HostInfo that 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 the HostInfo 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 name
      key - key to look for
      serializer - Serializer for the key
      Returns:
      the HostInfo where 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 the KeyQueryMetadata 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 name
      key - key to look for
      serializer - Serializer for the key
      Returns:
      the KeyQueryMetadata if 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 the KafkaStreams object 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 name
      key - key to look for
      serializer - Serializer for the key
      Returns:
      KafkaStreams object associated with this combination of store and key
    • getAllHostsInfo

      public List<org.apache.kafka.streams.state.HostInfo> getAllHostsInfo(String store)
      Gets the list of HostInfo where 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 HostInfo where provided store is hosted on