All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.jeqo.dropwizard.kafka.KafkaStreamsStoreHelper Maven / Gradle / Ivy

There is a newer version: 0.1.2
Show newest version
package io.github.jeqo.dropwizard.kafka;

import org.apache.kafka.streams.KafkaStreams;
import org.apache.kafka.streams.errors.InvalidStateStoreException;
import org.apache.kafka.streams.state.QueryableStoreType;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 */
public class KafkaStreamsStoreHelper {
  private static final Logger LOGGER = Logger.getLogger(KafkaStreamsStoreHelper.class.getName());

  public static  T waitUntilStoreIsQueryable(
      final String storeName,
      final QueryableStoreType queryableStoreType,
      final KafkaStreams streams)
      throws InterruptedException {
    while (true) {
      try {
        return streams.store(storeName, queryableStoreType);
      } catch (InvalidStateStoreException | IllegalStateException ignored) {
        LOGGER.log(Level.WARNING, "error with state");
        // store not yet ready for querying
        Thread.sleep(100);
      }
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy