What do you mean by "execute" here? I assume that you mean "can the same app handle both grpc and rest requests?". I never used quarkus, but I have a very good expertise in vertx. Quarkus uses vertx under the hood, it's basically vertx + DI + glue/sugar code to enhance and simplify vertx stuff + lots of integrations. If you put the question this way - "is it possible in vertx app to handle both rest and grpc requests" - then answer is yes. To do that in vertx, the key part is to set selector by content type, so all grpc requests go to grpc handler, and all the other requests - to the other route handlers. var grpcServer = GrpcIoServer.server(vertx) // .... register all handlers for grpc server var router = Router.router(vertx) router.route().consumes('application/grpc').handler { grpcHttpReq -> grpcServer.handle(grpcHttpReq) } router.route().handler { nonGrpcHttReq -> ....} Grpc requests are http2 requests that always have "content-type: application/grpc" header. That's the key part. Vertx documentation for this subject: https://vertx.io/docs/vertx-grpc/java/ Also, another obvious approach is to start two separate http servers on different ports. You can do that easily in vertx var grpcHttpSrv = vertx.createHttpServer(); var restHttpSrv = vertx.createHttpServer(); var grpcRouter = Router.create(vertx); var restRouter = ... // set them up separately grpcHttpSrv.listen(grpcPort); restSrv.listen(restPort); But at a glance, I highly doubt that quarkus can do that, and that there's a way that all that "glue/sugar code to enhance and simplify vertx stuff" quarkus code is prepared to distinguish between two separate servers under the hood. So if you figure out how to get to that router that is used under the hood of quarkus, AND if it's possible to customize these pieces, you should be able to do that. It may just happen that quarkus unconditionally registers grpc handler this way, without "content-type" selector router.route().handler { anyReq -> grpcServer.handle(anyReq) } If that's the case, you can't do anything about it. Quarkus documentation is total crap, unstructured pile of hello-world-ish how-to guides. I can't find anything about router quickly there. Hence, the answer is in the quarkus code itself. Also, there's a hint here: https://quarkus.io/guides/grpc-getting-started#different-grpc-implementations-types Another thing to take note as well is that Quarkus' gRPC support currently includes 3 different types of gRPC usage: - old Vert.x gRPC implementation with a separate gRPC server (default) - new Vert.x gRPC implementation on top of the existing HTTP server - xDS gRPC wrapper over grpc-java with a separate Netty based gRPC server If I understand it correctly, first approach is about runnting two separate http servers on different ports. Second is about having the same http server with "content-type: application/grpc" selector. And third one is again about a separate http server for grpc, but on the lowest level (netty). So based on this piece of documentation, it should be possible, and it feels that it's possible in all 3 kind of setups.
Thanks, I will check that
Обсуждают сегодня