// must use manual thread model according to Mina documentation
connectorConfig.setThreadModel(ThreadModel.MANUAL);
configureCodecFactory("MinaProducer", connectorConfig, configuration);
connectorConfig.getFilterChain().addLast("threadPool", new ExecutorFilter(Executors.newCachedThreadPool()));
if (minaLogger) {
connectorConfig.getFilterChain().addLast("logger", new LoggingFilter());
}
// set connect timeout to mina in seconds
connectorConfig.setConnectTimeout((int) (timeout / 1000));
// acceptor connectorConfig
SocketAcceptorConfig acceptorConfig = new SocketAcceptorConfig();
// must use manual thread model according to Mina documentation
acceptorConfig.setThreadModel(ThreadModel.MANUAL);
configureCodecFactory("MinaConsumer", acceptorConfig, configuration);
acceptorConfig.setReuseAddress(true);
acceptorConfig.setDisconnectOnUnbind(true);
acceptorConfig.getFilterChain().addLast("threadPool", new ExecutorFilter(Executors.newCachedThreadPool()));
if (minaLogger) {
acceptorConfig.getFilterChain().addLast("logger", new LoggingFilter());
}
MinaEndpoint endpoint = new MinaEndpoint(uri, this);
endpoint.setAddress(address);
endpoint.setAcceptor(acceptor);