CompletionStage<List<Employee>> getAll() { return client .preparedQuery("SELECT id, name FROM employee ORDER BY id ASC") .thenApply(pgRowSet -> { List<Employee> list = new ArrayList<>(pgRowSet.size()); pgRowSet.forEach(row -> list.add( new Employee(row.getLong("id"), row.getString("name")) )); return list; }); } }
getAll() { return client .preparedQuery("SELECT id, name FROM employee ORDER BY id ASC") .thenApply(pgRowSet -> { List<Employee> list = new ArrayList<>(pgRowSet.size()); pgRowSet.forEach(row -> list.add( new Employee(row.getLong("id"), row.getString("name")) )); return list; }); } } 17 で管理された コネクションプール
getAll() { return client .preparedQuery("SELECT id, name FROM employee ORDER BY id ASC") .thenApply(pgRowSet -> { List<Employee> list = new ArrayList<>(pgRowSet.size()); pgRowSet.forEach(row -> list.add( new Employee(row.getLong("id"), row.getString("name")) )); return list; }); } } 18 戻り値は 型。 よって 応答待ちのブロックをせずに、 メソッドは直ちに応答する。
getAll() { return client .preparedQuery("SELECT id, name FROM employee ORDER BY id ASC") .thenApply(pgRowSet -> { List<Employee> list = new ArrayList<>(pgRowSet.size()); pgRowSet.forEach(row -> list.add( new Employee(row.getLong("id"), row.getString("name")) )); return list; }); } } 19 実行したい を書く
getAll() { return client .preparedQuery("SELECT id, name FROM employee ORDER BY id ASC") .thenApply(pgRowSet -> { List<Employee> list = new ArrayList<>(pgRowSet.size()); pgRowSet.forEach(row -> list.add( new Employee(row.getLong("id"), row.getString("name")) )); return list; }); } } 20 io.vertx.axle.sqlclient.RowSet型から SQL結果行(row)を取ってきて、 Employee型に詰め替える
RUNNABLE at sample.quarkus.crud.spring.EmployeeController.get(EmployeeController.java:23) ... at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:122) at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:594) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:468) ... at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238) …. at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:118) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.lambda$handle$0(VertxRequestHandler.java:74) at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$$Lambda$438/147870592.handle(Unknown Source) at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:316) at io.vertx.core.impl.ContextImpl$$Lambda$432/1558995732.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ... 見た目Spring / 中身Vert.x+RESTEasy 上で を動かすために で作り込んだレイヤ