I'm trying to build a caching ServerInterceptor which will be the first in a chain of interceptors. I managed to get the basic functionality working by returning a SimpleForwardingServerCallListener which checks a cache in the onMessage method, and manually sending the headers and response and closing the call in case of a cache hit, otherwise delegating to next.startCall(...). However, it seems like next.startCall(...) causes the call to cascade to the subsequent interceptors, and onMessage on the listener is only called after that.
My searches have come across:
and a few others where it seems like it possible to delay next.startCall(...) until after the first message is received. I tried to do something akin to https://github.com/grpc/grpc-java/issues/5414#issuecomment-468754271 using a noop listener, but then the onMessage on the listener never seems to be called at all.
Am I missing something obvious?
PS. A big thank you to all the maintainers