Skip to content

Is It Possible to Dynamically Replace Marshallers on the Server Side Based on Request Metadata? #12302

@amnagmv

Description

@amnagmv

I'm working on securing gRPC communications between Java applications by encrypting payloads at the application level. On the client side, I was able to implement this cleanly using a ClientInterceptor that replaces the marshallers with custom ones that handle encryption and decryption.

However, on the server side, I’ve found that ServerInterceptor and ServerCallHandler don't allow replacing the MethodDescriptor or its marshallers dynamically. Since the marshaller is used before the interceptor runs, it’s not possible to decrypt the payload based on request-specific metadata — such as a sessionId passed in the headers.

The only workaround I’ve found is to use a wrapper protobuf message (e.g., EncryptedRequest) and manually decrypt the payload inside the service logic. While this works, it mixes transport-level concerns with business logic and reduces maintainability.

Is there currently a way to dynamically replace or configure marshallers per request on the server side?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions