Search code examples
javaspringrx-java2querydslspring-data-cassandra

Spring Data Cassandra Query DSL RxJava2


So I am using Spring Data Cassandra and RxJava, I am looking for a way to use RxJava Observable with custom query building (the find..by abstraction is to complicated to use in my case) and I was planning on using QueryDSL (the method findAll(Predicate), but it does not enable Async :/)

So far my best shot is to use AsyncCassandraTemplate to build a Query and return it as ListenableFuture so that it can be mapped to a Observable and be used with RxJava's Observable. Is there any other way?


Solution

  • There's no QueryDsl support Spring Data for Apache Cassandra. You can use Query objects to create queries and ReactiveCassandraTemplate for reactive API usage:

    Mono<Person> person = cassandraTemplate.selectOneById(query(where("age").is(33)), Person.class);
    Maybe<Person> maybe = Flowable.fromPublisher(person).firstElement();