I Created the managed channel with a thread pool executor.
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 6565)
.executor(Executors.newFixedThreadPool(7))
.usePlaintext()
.build();
this.clientStub = StockQuoteProviderGrpc.newStub(channel);


the expectation was that the messages which i will receive in observer will 
be out of order  as ClientCallImpl<ReqT, RespT>.class has 
callExecutor.execute(new MessagesAvailable());

public class StockResponseStreamObserver implements 
StreamObserver<StockQuote> {

AtomicInteger atom = new AtomicInteger(0);
@Override
public void onNext(StockQuote stockQuote) {

if(atom.incrementAndGet()%5==0){
System.out.println("T sleeping for 1000 ms " + Thread.currentThread
().getName());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println(LocalDateTime.now() +" : "+ stockQuote.getPrice()+" 
description:"+ stockQuote.getDescription()+" T "+Thread.currentThread
().getName());

}

but the output is always printed in sequence even with thread.sleep to a 
random thread.

is this an expected behaviour?

Thanks
Mayank


-- 
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/a58e3540-aa70-4576-a50c-9f19de47e0e1n%40googlegroups.com.

Reply via email to