Search code examples
apache-kafkaapache-kafka-streams

Fetch records from kafka data store (Rocks DB) based on condition


Right now I am using kafka data store (Rocks DB) for storing intermediate data from topics. I had written some interactive queries on top of this using https://kafka.apache.org/20/documentation/streams/developer-guide/interactive-queries.html

// Get the values for all of the keys available in this application instance

KeyValueIterator<String, Employee> range = keyValueStore.all(); 
while (range.hasNext()) {   
KeyValue<String, Employee> next = range.next();  

System.out.println("count for " + next.key + ": " + value); 
}

Employee record saved is Employee(id, name)
Sr.No.  Id      Name
1       emp_1   John
2       emp_2   Jamie
3       emp_3   John

Now I need all the employee's with name John. I could not find any solution to get data based on this(where) clause. Right now I am getting all the records and filtering that in my java code. Please suggest if any other solution is there. I want all the records to filtered when I am fetching them.


Solution

  • getting all the records and filtering that in my java code

    That is the correct way to do it.

    If you really want "WHERE clauses", you will want to look at ksqlDB, which can be embedded in Java code