InboundMessageDispatcher implements ResponseMessageHandler { public void enqueue( ResponseHandler handler ) { if ( fatalErrorOccurred ) { handler.onFailure( currentError ); } else { handlers.add( handler ); updateAutoReadManagingHandlerIfNeeded( handler ); } } InboundMessageDispatcher( Channel channel, Logging logging ); void enqueue( ResponseHandler handler ); int queuedHandlersCount(); @Override void handleSuccessMessage( Map<String,Value> meta ); @Override void handleRecordMessage( Value[] fields ); @Override void handleFailureMessage( String code, String message ); @Override void handleIgnoredMessage(); void handleChannelError( Throwable error ); void clearCurrentError(); Throwable currentError(); boolean fatalErrorOccurred();  }
@Test void shouldKeepSingleAutoReadManagingHandler() { InboundMessageDispatcher dispatcher = newDispatcher(); ResponseHandler handler1 = newAutoReadManagingResponseHandler(); ResponseHandler handler2 = newAutoReadManagingResponseHandler(); ResponseHandler handler3 = newAutoReadManagingResponseHandler(); dispatcher.enqueue( handler1 ); dispatcher.enqueue( handler2 ); dispatcher.enqueue( handler3 ); InOrder inOrder = inOrder( handler1, handler2, handler3 ); inOrder.verify( handler1 ).disableAutoReadManagement(); inOrder.verify( handler2 ).disableAutoReadManagement(); inOrder.verify( handler3, never() ).disableAutoReadManagement(); }