I'm new to quarkus and reactive programming. I'm currently facing an issue with quarkus-reactive-postgresql extension.
I have a list containing events that perform a database update. Each event has to be updated independently (so I don't use a transaction).
Here is my web service:
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Uni<JsonObject> synchro(List<Event> events) {
List<Uni<RowSet<Row>>> queries = new ArrayList<>();
List<Event> success = new ArrayList<>();
List<Event> fails = new ArrayList<>();
for (Event evt : events) {
// Perform update
var query = client.preparedQuery("My failing query")
.execute(Tuple.of(evt.field));
// Subscribe. It's ok. Add event to success list
query.subscribe().with(unused -> success.add(evt));
// It's failure. Add event to failures
query.onFailure(throwable -> {
log.error(String.format("Unable to update event %s", evt.toString()), throwable);
fails.add(evt);
return true;
});
queries.add(query);
}
return Uni.combine().all().unis(queries)
.combinedWith(ArrayList::new)
.onItem().transform(list -> new JsonObject()
.put("success", success.stream().map(Event::toJson).collect(Collectors.toList()))
.put("errors", fails.stream().map(Event::toJson).collect(Collectors.toList()))
);
}
Quarkus reactive pg extension throws an exception :
2021-08-06 10:35:37,665 ERROR [io.qua.mut.run.MutinyInfrastructure] (vert.x-eventloop-thread-23) Mutiny had to drop the following exception: io.vertx.pgclient.PgException: { "message": "column \"fake_column\" of relation \"table\" does not exist", "severity": "ERROR", "code": "42703", "position": "18", "file": "analyze.c", "line": "2263", "routine": "transformUpdateTargetList" }
However, .onFailure is not triggered and ever fill my failures list.
Is it a bug or something goes wrong with my code ?
Thanks for your help,