Vertx 4.0 is released
https://vertx.io/blog/eclipse-vert-x-4-released/
https://vertx.io/blog/eclipse-vert-x-4-released/
用 Quarkus 吧,基础是 CDI+Vertx.
https://github.com/hantsy/quarkus-sample/tree/master/vertx-routes-munity/src/main/java/com/example
https://github.com/hantsy/vertx-sandbox
遇到两个问题需要解决:
1 。 如何全局注册 ObjectMapper ? Quarkus 有 CDI 帮助写一个 Bean 就行了。
2 。PgPool 如何优雅的 Close 。Quakus 的 PgPool 内置,开箱即用的,CDI 有 Disposible 监控。
纯粹编程式的代码,不用 Annotation,DI 等,这与 Helion SE 类似。https://github.com/hantsy/helidon-sample/blob/master/se-dbclient/src/main/java/demo/Main.java, 不过,Helidon SE 提供一些强制的接口,如 Service 。
Future 中有对应 Java 8 Stage 的 thenAccept 方法吗?
2. 有时简单的用 object Foo{},不需要搞 ioc,连接口都不用定义。
3. Future 我完全不用,全部用协程了。
4. 目前仍然比较麻烦的地方,很多 client 不能多线程 share,这个问题本来在 4.0 的时候会解决,一再延期搁置了。本来打包票说好 2019 年发 4.0 。
5. 可能 blocking code 和 non blocking code 之间的衔接,还需要找到更简单的办法。
vertx 做点服务挺好的,但是拿来写 crud,跟纯用 springboot 那套比,还是差一些。
Quarkus 的 Vertx Extensions 降低门槛,有了 CDI,很多基础的东西都是 outbox 了。
Quarkus 由于一开始就为 Native 准备,不能随意添加依赖,必须是 Quarkus Extensions, 好在 Quarkus 算是比较活跃,一般能用到的框架,工具等都是提供了集成。
Vertx pg client 等也是 Hibernate Reactive 的基础,Hibernate Reactive 刚发布了 1 。0 候选版本,Hibernate 使用与 Quarkus 一致的类型,Java 8 CompletionStage 和 Redhat 自家的 Smallrye Munity (也是 Redhat 实现 Microprofile Reactive Messages 的基础)。https://download.eclipse.org/microprofile/microprofile-reactive-messaging-1.0/microprofile-reactive-messaging-spec.pdf
说到这个 Microprofile Reactive Messages, 在 Quarkus 的使用真的好简单,可以直接把消息导到 SSE,WebSocket,这点比 Spring 简单多了。
https://github.com/hantsy/quarkus-sample/blob/master/amqp/src/main/java/com/example/MessageResource.java#L22