As I understand, Micronaut benefit from non-blocking i/o. In my project I need to use MySQL as data storage.
I would love to use GORM or a similar ORM to easy the access but they are blocking AFAIK.
Coming from Vertx, there is executeBlocking
to execute in the thread pool blocks of sync code while not blocking the main loop.
So my question have two edges.
First, which ORM could I use to connect to MySQL, similar to GORM, but non blocking.
And Second, if there is a way, or benefit like in Vertx, to execute sync code keeping most part of the method async.
I am not aware of any non-blocking ORMs and I don't whether it is even technically possible to implement all the features of an ORM in a non-blocking away. Take for example lazy loading an associations, if you access an association like book.authors
you have to block to execute the query and load the association.
There are however non-blocking SQL drivers. You could try use the Vert.x driver https://vertx.io/docs/vertx-mysql-postgresql-client/java/ within Micronaut
As for running blocking operations, Micronaut has a simple strategy. If you return a reactive type is subscribes to the reactive type on the event loop, if you don't it runs the operation on a pre-configured I/O thread pool.
So simply returning List<Book>
will run the operation on I/O thread pool unless you annotate the method with @NonBlocking
See https://docs.micronaut.io/latest/guide/index.html#threadPools