How to pass data from rpc server call to server interceptor in java?

25 views
Skip to first unread message

preeth...@gmail.com

unread,
Aug 5, 2019, 10:52:42 AM8/5/19
to grpc.io
Hi all,

I am trying to set some metadata after the rpc server call has been processed. The plan was to use server interceptor and override `close` method. 

Something like this: https://github.com/dconnelly/grpc-error-example/blob/master/src/main/java/example/Errors.java#L38 

But the metadata value depends on the response. So I need some way to pass data from rpc server call to server interceptor. 


In  Golang, the metadata can be set easily in the rpc call `grpc.SetTrailer` after processing but in java there is no way to do it  in rpc call. So I am trying to use server interceptor for the same.

Can someone help?

Kun Zhang

unread,
Aug 7, 2019, 2:05:45 PM8/7/19
to grpc.io
You can also override sendMessage() on the forwarding ServerCall, save the information you need from the response, and use it in the overridden close().
Reply all
Reply to author
Forward
0 new messages