Generally the message will be a protobuf message, so you can cast to com.google.protobuf.Message (after doing an instanceof check). You can then use a method like message.getAllFields to introspect. If a field contains a message, you can process the tree recursively.
On Thu, Jun 17, 2021 at 7:36 PM Bill Li <[email protected]> wrote: > Hi, > > I have a question regarding how I can access each field of the input > request object in ServerInterceptor. The following is my code: > > public <ReqT, RespT> ServerCall.Listener<ReqT> > interceptCall(ServerCall<ReqT, RespT> serverCall, > Metadata metadata, > ServerCallHandler<ReqT, RespT> serverCallHandler) { > ServerCall.Listener<ReqT> listener = > serverCallHandler.startCall(serverCall, metadata); > return new > ForwardingServerCallListener.SimpleForwardingServerCallListener<>(listener) > { > @Override > public void onMessage(ReqT message) { > System.out.println(message.toString()); > super.onMessage(message); > } > }; > } > > After printing it out, the following output appears: > > request_config { > field_1: "field_1" > field_2: "field_2" > field_3: "field_3" > } > > I didn't find any obvious methods in the source code or examples online on > processing each fields in the message. Does anyone have examples on how to > access each field? > > Thanks, > Bill > > -- > You received this message because you are subscribed to the Google Groups " > grpc.io" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/grpc-io/bcb78a30-402b-4ea1-bea7-67b3c3912cf5n%40googlegroups.com > <https://groups.google.com/d/msgid/grpc-io/bcb78a30-402b-4ea1-bea7-67b3c3912cf5n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CA%2B4M1oPTDS-oHmZ1hvWEUeSPbnG2HU_t7hvWAVEUCNC2tCzMHQ%40mail.gmail.com.
smime.p7s
Description: S/MIME Cryptographic Signature
