Confused about RowPublisherOperation usage in ADBA

Frank Lyaruu frank at dexels.com
Mon Apr 22 09:09:05 UTC 2019


Hey all,

I'm trying to create a reactive-backpressure demo using ADBA.
It pretty much got it working with pgadba, but I'm a little bit confused
about the way I'm supposed to be using the API:

In RowPublisherOperation:

public RowPublisherOperation<T> subscribe(Flow.Subscriber<? super
Result.RowColumn> subscriber,CompletionStage<? extends T> result);

What is the purpose of the 'result' CompletionStage? I'm getting the
results through the subscriber. When the query completes, the subscriber
gets a completed signal, so I don't see the use of it.

If I pass an empty new CompletableFuture<>() to it, and ignore it after
that it seems to work but I'm unsure if that is correct and it won't be
leaking something somewhere.

Similarly, can I safely ignore the completionstage of the submission? It
seems I've got all the information I need from the subscriber stream.

        RowProcessor rp = new RowProcessor();
>         final CompletableFuture<String> completableFuture =
> session.<String>rowPublisherOperation("select title from film")
>                     .subscribe(rp, result)
>                     .submit()
>                     .getCompletionStage()
>                     .toCompletableFuture();
>

Moreover, if I want to cancel this stream, do I need to cancel both the
subscriber and the submission? Or is cancelling the subscriber enough? The
mix of Flow and CompletionStages makes my head hurt a bit.


More information about the jdbc-spec-discuss mailing list