gRPC java server with multiple services

48 views
Skip to first unread message

Ronald Sigal

unread,
Sep 16, 2024, 1:16:20 PMSep 16
to grpc.io
Hi,

My goal is to have a single gRPC port such that services / interceptors in each Web Archive are segregated from other WARs.

It seems that a io.grpc.internal.ServerImpl monitoring a port has a single
HandlerRegistry for methods and a single field for holding all ServerInterceptors.

Would I have to set up a port for each WAR to keep things separate?

By the way, the point of the project is to incorporate gRPC into the WildFly application
server.

Thanks,
Ron Sigal

Kannan Jayaprakasam

unread,
Sep 27, 2024, 7:24:42 AMSep 27
to grpc.io
Yes a single io.grpc.Server maintains a single registry as you pointed out. You could create one io.grpc.Server instance for each WAR  listening on distinct ports.

Ronald Sigal

unread,
Oct 1, 2024, 4:43:19 PMOct 1
to grpc.io
Hi Kannan,

Thank you for verifying my suspicion. In fact, what I have done was to manage the interceptors manually.

For each WAR:

  1. extract all services

  2. extract all interceptors

  3. for each method, use io.grpc.InternalServerInterceptors.interceptCallHandlerCreate() to wrap the interceptors "manually" and create a BindableService which gets stored in a MutableHandlerRegistry.

At the moment, the code is in a pull request: https://github.com/wildfly-extras/wildfly-grpc-feature-pack/pull/274. I expect there will be a release soon.

-Ron
Reply all
Reply to author
Forward
0 new messages