I have a custom implementation of request marshaller (overriding io.grpc.MethodDescriptor.Marshaller) which I want to use, but I would need context information related to the microservice call (specifically microservice method name being invoked). I tried populating it in ServerInterceptor's interceptCall. My interceptor code looks like this:
@OverrideBut the context populated does not persist when unmarshalling of the request stream takes place.
This is because io.grpc.internal.ServerImpl.ServerTransportListenerImpl#streamCreatedInternal creates new io.grpc.internal.ServerImpl.JumpToApplicationThreadServerStreamListener and populates context using io.grpc.internal.ServerImpl.ServerTransportListenerImpl#createContext which just adds deadline and serverImpl instance fields over rootContext. So, the information I populated was not available during unmarshalling. Also, populating it in onMessage would not be useful too, since io.grpc.internal.ServerCallImpl.ServerStreamListenerImpl#messagesAvailableInternal uses
listener.onMessage(call.method.parseRequest(message));so parseRequest executes before onMessage is triggered.
Is there some way to pass context information to marshaller, or maybe use method name there. I am constructing methodDescriptor using io.grpc.MethodDescriptor.Builder