Quarkus 反应式客户端 MySql 客户端未插入记录
Quarkus reactive client MySql client is not inserting records
我正在使用 Quarkus 1.1.0.Final 为 Quarks-Mysql 反应式客户端做一个 poc。代码如下:
public void put() {
mysqlPool
.begin(ar ->{
if(ar.succeeded()) {
Transaction tx = ar.result();
tx.preparedQuery(
"insert into Book(categoryType, description, isbn, name, price, totalBuyers) values(?, ?, ?, ?, ?, ?)",
Tuple.of(1, "Fresh one", "ISBN-0", "Fresh", 100.0, 0),
qr -> {
if(qr.succeeded()) {
tx.commit(txr -> {
if(txr.succeeded()) {
System.out.println("Successful !!!");//Is not printing
} else {
System.err.println("Failed !!!");//Is not printing
}
});
}
tx.close();
});
}
});
}
调用 tx.commit 后,没有返回异步结果(成功或失败),也没有新记录插入数据库。每次调用后自动 ID 都会增加。我正在使用 this.
检查它
我的 application.properties 是:
quarkus.datasource.url = vertx-reactive:mysql://localhost:3306/ebs_book
quarkus.datasource.username = xxx
quarkus.datasource.password = xxx
我正在使用带有最新标签的mysql官方图片。
我是不是漏掉了什么?
此外,如果任何人都可以提供和 reactx 扩展相等的代码会更好。我不喜欢复合回调!
你不应该在 commit()
之后调用 tx.close()
,因为它会安排一个 ROLLBACK
查询,关于如何使用事务 API,请查看 official documentation .
关于 reactiveX 扩展代码,您可以访问 page,它在 PostgreSQL 客户端文档中,但我认为 API 与 MySQL 客户端相同,我相信它可以改进为也包含在 MySQL 文档中。
此外,我无法重现您遇到的问题,如果问题仍然存在,能否请您提供一个重现器并在 https://github.com/eclipse-vertx/vertx-sql-client/issues 中打开一个问题?
我正在使用 Quarkus 1.1.0.Final 为 Quarks-Mysql 反应式客户端做一个 poc。代码如下:
public void put() {
mysqlPool
.begin(ar ->{
if(ar.succeeded()) {
Transaction tx = ar.result();
tx.preparedQuery(
"insert into Book(categoryType, description, isbn, name, price, totalBuyers) values(?, ?, ?, ?, ?, ?)",
Tuple.of(1, "Fresh one", "ISBN-0", "Fresh", 100.0, 0),
qr -> {
if(qr.succeeded()) {
tx.commit(txr -> {
if(txr.succeeded()) {
System.out.println("Successful !!!");//Is not printing
} else {
System.err.println("Failed !!!");//Is not printing
}
});
}
tx.close();
});
}
});
}
调用 tx.commit 后,没有返回异步结果(成功或失败),也没有新记录插入数据库。每次调用后自动 ID 都会增加。我正在使用 this.
检查它我的 application.properties 是:
quarkus.datasource.url = vertx-reactive:mysql://localhost:3306/ebs_book
quarkus.datasource.username = xxx
quarkus.datasource.password = xxx
我正在使用带有最新标签的mysql官方图片。
我是不是漏掉了什么? 此外,如果任何人都可以提供和 reactx 扩展相等的代码会更好。我不喜欢复合回调!
你不应该在 commit()
之后调用 tx.close()
,因为它会安排一个 ROLLBACK
查询,关于如何使用事务 API,请查看 official documentation .
关于 reactiveX 扩展代码,您可以访问 page,它在 PostgreSQL 客户端文档中,但我认为 API 与 MySQL 客户端相同,我相信它可以改进为也包含在 MySQL 文档中。
此外,我无法重现您遇到的问题,如果问题仍然存在,能否请您提供一个重现器并在 https://github.com/eclipse-vertx/vertx-sql-client/issues 中打开一个问题?