简体   繁体   中英

Kafka Streams Binding: Cannot get state store because the stream thread is PARTITIONS_ASSIGNED, not RUNNING

I use the infrastructure of Spring Cloud Stream Kafka Binding for stream processing.

Here is the main KafkaStream-methods:

private static final String READ_STORE_NAME = "readMessageStore";

  @Bean
public Consumer<KStream<String, ContentModel>> filter() {
    return in -> in.groupByKey(Grouped.with(Serdes.String(), new JsonSerde<>(ContentModel.class)))
            .reduce(this::mergeObjects, Materialized.as(READ_STORE_NAME));
}

private ContentModel mergeObjects(final ContentModel reducer, final ContentModel materialized) {      
    return reducer;
}

Configuration of binding:

spring.cloud.stream.bindings.filter-in-0:
     destination: topic

I deploy 2 instances of application, which separated by ApplicationId as follows:

spring.cloud.stream.kafka.streams.binder.functions.filter.applicationId = <Id>

But on the stage of deploy I receive:

IllegalStateException: Error when retrieving state store: j readMessageStore

Caused by: org.apache.kafka.streams.errors.InvalidStateStoreException: Cannot get state store readMessageStore because the stream thread is PARTITIONS_ASSIGNED, not RUNNING

From that Unable to open store for Kafka streams because invalid state I found out, that I need (apparently) to wait for the second RUNNING state before query.

But how can I set this delay in the Spring Cloud Stream Kafka Binding environment, considering that all state transitions in this case realized "under the hood"?

You need to enable the health indicator and then write the listener to monitor it for REBALANCE before the second RUNNING.

refer this Health Indicator

I do not have enough rep to comment, therefore I'm asking this in an answer. Did you find a solution for this problem?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM