I'm using Apache Cayenne with Vertx. Vertx relies on everything to be asynchronous and it actively looks for threads that block.
So performing something like...
List<Artist> artists = ObjectSelect.query(Artist.class).select(context);
...will result in Vertx complaining with the following:
WARNING: Thread Thread[vert.x-eventloop-thread-0,5,main] has been blocked for 4750 ms, time limit is 2000
Please note that there are in fact ways to get around this by wrapping the code in an executeBlocking
function as follows:
// Turning synchronous code to async in Vertx
vertx.executeBlocking<Any>({ future ->
List<Artist> artists = ObjectSelect.query(Artist.class).select(context)
future.complete(artists)
}, { res ->
// The result
})
However, it becomes a pain to keep wrapping my ORM functions like that.
I wonder if there's a flag or a switch to turn Cayenne asynchronous? Or, if there isn't such a flag, I wonder if there's a way to use the Postgres Async Driver by Mauricio. I pick that specific async driver because Vertx provides native support for it.