[gRPC java] Using newFutureStub for Fire-and-Forget calls

20 views
Skip to first unread message

Martin Muñoz

unread,
Feb 23, 2026, 10:36:10 AM (5 days ago) Feb 23
to grpc.io
Hi everyone,

I’m planning to implement a fire-and-forget call in grpc-java and I have a question about the implications.

What happens if service A invokes an RPC on service B using newFutureStub, but never retrieves the response (i.e., I don’t call get() or register any callbacks)? Are there any risks in terms of thread usage or unreleased resources? Would this be considered a recommended practice?

I understand that if service A finishes before service B completes processing, there’s a risk that the context in B could be cancelled. I could mitigate this by forking the context. However, my main concern is whether invoking a future-based RPC without ever waiting for or consuming the response violates any design principles or best practices in gRPC, and whether it could lead to hidden resource or lifecycle issues

Here's a simple example of what the call to service B would look like:
public void callFuturegRPC(Empty request, StreamObserver<Empty> responseObserver) {
    ManagedChannel channel = ...

    ServiceBGrpc.ServiceBFutureStub futureStub =   ServiceBGrpc.newFutureStub(channel);

    ListenableFuture<ResponseB> future = futureStub.exampleRpc(RequestB.newBuilder().setField1("test").build());

    responseObserver.onNext(Empty.newBuilder().build());
    responseObserver.onCompleted();
}

Thanks a lot!

Reply all
Reply to author
Forward
0 new messages