If you want messages to arrive in a particular order, you should send all of those messages on the same stream.
If for some reason that is not an option, you could instead define the order in the RPC method definition. For example, you could add a sequence number that is shared across both streams to the response message type. Then the client can use those sequence numbers to reconstruct the proper order after receiving the messages. If one stream gets too far ahead of the other, the client could simply stop reading from that stream temporarily to allow the other one to catch up. On Thu, Feb 6, 2020 at 2:06 AM <dellinspiron5...@gmail.com> wrote: > Hello, > > I have a gRPC server with 2 streams, both providing events. Messages are > posted on these stream from the same thread. For testing I send a message > from stream1, then stream2, etc. On client side I need to keep that order > when receiving the messages. > > By default on client side there are multiple threads that will come in the > way, I was able to fix the issue on that side using a SerialExecutor (like > the one documented in java.util.concurrent.Executor). Now my client is well > receiving on one thread. > > However the order of the messages is still wrong. For example, I can get 5 > messages from stream1 in a row. My guess is that the server is opening > multiple connection to serve the messages. How can I fix that and keep my > messages in order? > > Regards, > > Bob > > -- > 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/f9163ab6-db3b-4ab9-9119-62c3641fe82f%40googlegroups.com > <https://groups.google.com/d/msgid/grpc-io/f9163ab6-db3b-4ab9-9119-62c3641fe82f%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CAPK2-4cNNWLdsikuiAK0xtEGCfHYTKwgRqEs60xuaH6q3u%3D%3DBQ%40mail.gmail.com.
smime.p7s
Description: S/MIME Cryptographic Signature