public static ModelControllerClient createReceiving ( final Channel channel , final ExecutorService executorService ) { final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy . create ( channel ) ; final ManagementChannelHandler handler = new ManagementChannelHandler ( strategy , executorService ) ; final ExistingChannelModelControllerClient client = new ExistingChannelModelControllerClient ( handler ) ; handler . addHandlerFactory ( client ) ; channel . addCloseHandler ( new CloseHandler < Channel > ( ) { @ Override public void handleClose ( Channel closed , IOException exception ) { handler . shutdown ( ) ; try { handler . awaitCompletion ( 1 , TimeUnit . SECONDS ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; } finally { handler . shutdownNow ( ) ; } } } ) ; channel . receiveMessage ( handler . getReceiver ( ) ) ; return client ; }
Create a model controller client which is exclusively receiving messages on an existing channel .