Skip to content

Stream Processing with SQL

This page shows how to processing stream data in HStreamDB with SQL using Java SDK.


Make sure you have HStreamDB running and accessible.

Execute Real-time Query on Stream

Here is an example:

Observer<HRecord> observer =
    new Observer<HRecord>() {
      public void onNext(HRecord value) {
        System.out.println("get hrecord: {}" + value);

      public void onError(Throwable t) {

      public void onCompleted() {}

Queryer queryer =
        .sql("select * from test_stream where temperature > 30 emit changes;")

// queryer will fetch real-time data at background

// ... execute query for some time ...

// finally, you can stop the queryer using queryer.stopAsync()

You can use a Queryer object to create a real-time SQL statement, also you need to provide an Observer object which contains your logic for processing the results returned by the query. The Queryer will process data in a background thread.

Back to top