I am using quarkus-narayana-jta for transaction management and using reactive MysqlPool to insert into db. MysqlPool class is not Autoclosable so do we need to explicitly call close() method from Pool class to close in case failure occurs or is it fine to just print the error message to the log and let transaction manager rollback the entire transaction in case failure occurs. What will be the impact if in case MySqlPool is not closed explicitly.
@Transactional
public Uni<String> insertIntoDb(BaseLog baseLog) {
LocalDate currentDate = LocalDate.now();
int year = currentDate.getYear();
if (baseLog instanceof RequestLog) {
prepareRequestLogData(baseLog, currentDate, year);
}
if (baseLog instanceof ResponseLog) {
prepareResponseLogData(baseLog, currentDate, year);
}
return mysqlPool.preparedQuery(query).execute().onItem()
.transformToUni(id -> mysqlPool
.query("SELECT TRAN_ID FROM " + tableName + " ORDER BY TO_DB_TS DESC LIMIT 1").execute())
.onItem().transform(rows -> rows.iterator().next().getString(0)).onFailure().invoke(f -> {
LOG.error("Error while inserting data to " + tableName + " table::" + f.getMessage());
});
}