I'm using a Java client that returns a CompleteableFuture (StreamedQueryResult extends Publisher). And I'm trying to convert this to a flux and emit values as they're received. The client connection will be infinite so I believe the issue might be that the CompleteableFuture is never completed? If that's the cause how can I convert this stream of values into a Flux and emit those as they're received?
client.streamQuery() returns CompleteableFuture<? extends Publisher<?>>
Here is my findAll() method where I call the client. It successfully prints received as expected.
@Override
public Flux<Person> findAll() {
return Flux.from(client.streamQuery("select * from deal_change emit changes;").join()).flatMap(row -> {
System.out.println("received");
try {
return Flux.just(mapper.readValue(row.asObject().toJsonString(), Person.class));
} catch (JsonProcessingException e) {
return Flux.empty();
}
});
}
Here is the example where I'm calling the method above. But nothing is ever returned and none of the below is ever printed.
var repo = new PersonRepository(client);
var person = repo.findAll().map(p -> {
System.out.println("test");
return p;
}).blockFirst();
System.out.println(person);
System.out.println("end");