You might use CompletableFuture.supplyAsync <https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html#supplyAsync-java.util.function.Supplier-java.util.concurrent.Executor-> (Supplier <https://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html> <U> supplier, Executor <https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Executor.html> executor)
and pass the second argument as context.fixedContextExecutor() or Context.currentContextExecutor(). On Monday, November 16, 2020 at 11:54:35 PM UTC-8 [email protected] wrote: > Hi, > > I have Service A which has to call Service B and C asynchronously. So i > used Java 8 CompletableFuture supplyAsync method. > > *Problem: * > Service A gets JWT token from the caller , using Server interceptor it > validates the token and if the token is valid it is set in the gRPC Context > to propagate token to further client calls. > > When i put the CompletableFuture , it creates a new thread for Service B > and C calls so the gRPC context where the token set is lost. Service B and > C calls are failing with missing token. > > > Background: Earlier Service A calls only B. So the ServerInterceptor which > sets the token was available in clientInterceptor for calling B. > > As a new enhancement added Service C call. > > > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/b10d5273-a1ac-4b32-86e3-6a08ab2e3cc1n%40googlegroups.com.
