Search code examples
javaspringjooqreactiver2dbc

Execute procedures reactively using jooq


Im having trouble running JOOQ routines in a reactive way. My Spring project is set up with R2DBC, and the DSLContext bean uses its connection factory.

I have a database procedure that I want to execute directly from my code using Project Reactor.

Whats the best way to do this?

Here's my current code:

private final DSLContext dslContext;

@Override
public Mono<Void> upsertJobContent(UpsertJobContentData data) {
    var routine = toUpsertJobBaseDataRoutine(data);
    return Mono.fromRunnable(() -> routine.execute(dslContext.configuration()));
}

private UpsertJobBaseData toUpsertJobBaseDataRoutine(UpsertJobContentData data) {
    UpsertJobBaseData procedure = new UpsertJobBaseData();
    procedure.setPCompanyId(data.getCompanyId());
    procedure.setPTitle(data.getJobTitle());
    ...
    return procedure;
}

Solution

  • As of jOOQ 3.19, this isn't supported, see the list of known limitations:

    Given the complexity of this particular task, and the already declining attractiveness of the reactive programming model in the community, as well as how few additional RDBMS are supporting R2DBC, it's unlikely it will be a priority in the near future.

    Just use JDBC for routine calls.