Hey Darshan,

Right now I'm not entirely sure I'll be able to answer your question with 
absolute confidence.
I'd like to say "yes, stream is created on first headers sent, and stream 
id not going to change until RPC dies", but there might be some nuances 
depending on the transport used, f.e. Netty's StreamBufferingEncoder. I'll 
speak with my TL to clarify this.
I don't think there's a clear way to get the stream ID, except I've noticed 
it's tracked via PerfMark <https://github.com/perfmark/perfmark> when it's 
enabled:
https://github.com/grpc/grpc-java/blob/68eb639b1cd38c161a3113bd50e731c04ac51fef/core/src/main/java/io/grpc/internal/ServerImpl.java#L464-L465
  
<https://github.com/grpc/grpc-java/blob/68eb639b1cd38c161a3113bd50e731c04ac51fef/core/src/main/java/io/grpc/internal/ServerImpl.java#L464-L465>

I'll follow up on your questions, but could you please clarify:

1. Your code snippet: are you talking about the client side, or the server 
side?
2. Is there anything specific you're trying to achieve?

Best Regards,
Sergii

On Monday, March 11, 2024 at 8:48:38 AM UTC-7 Darshan J Gowda wrote:

> Hi everyone,
> I'm trying to understand how many streams are getting created in one grpc 
> connection (Bidirectional streaming) whenever I call onNext() using a 
> StreamObserver object. Below is my code context
>
> StreamObserver<Response> responseStreamObserver1 = getResponseObserver();  
> StreamObserver<Response> responseStreamObserver2 = getResponseObserver();
> StreamObserver<Request> streamClientSender1 = 
> stub.sendRequest(responseStreamObserver1);
> StreamObserver<Mbus> streamClientSender2 = 
> stub.sendRequest(responseStreamObserver2);
>
> My question is, 
> 1. when the program calls streamClientSender1.onNext(request), request 
> will be sent in a stream, if I call it again will it be in the same stream 
> as long as the age of the stream is within max connection age ?
> 2. does streamClientSender1.onNext() and streamClientSender2.onNext() use 
> different streams to send request, since they are two different 
> streamObserver objects. 
> 3. Is there a way to get StreamID of streams created and print it as a 
> verification step so that the above two questions can be answered ?
>
> Thanks and regards,
> Darshan
>

-- 
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 grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/5b5ec411-1249-48ae-b711-9a8752815650n%40googlegroups.com.

Reply via email to