Java client streaming api questions

42 views
Skip to first unread message

cr2...@gmail.com

unread,
Jun 16, 2017, 4:03:39 PM6/16/17
to grpc.io
Hi
Are the Java steaming APIs thread safe ? 
If I have a StreamingObserver.onNext(<mydata>) with potentially multiple threads calling that
then  on the StreamObserver's implemented interface onNext method how can associate the response back to a specific 
 thread's call to the StreamingObserver.onNext(<mydata>) ?

Hope that made sense :)

Thanks in advance.

spenc...@google.com

unread,
Jun 19, 2017, 2:44:39 PM6/19/17
to grpc.io, cr2...@gmail.com
StreamObserver is not thread safe, so if multiple threads are producing data, you must synchronize the calls. You can find more details here:

Can you elaborate on your use and why multiple threads are writing on this streaming call, rather than having a call per thread?

cr2...@gmail.com

unread,
Jun 19, 2017, 2:56:24 PM6/19/17
to grpc.io, cr2...@gmail.com
Hi Thanks for the reply-  I was under the initial assumption that separate streaming stubs would create separate connections .. but the connection is on the managed channel so at the moment I've moved to just creating one per thread call.
Reply all
Reply to author
Forward
0 new messages