private void setBasicProperties () { final NioParams nioParams = new NioParams() .setNbIoThreads(1) .setWriteEnqueuingTimeoutInMs(0) .setWriteByteBufferSize(VALUE_SET_WRITE_BUFFER_SIZE); RABBITMQ_CONNECTION_FACTORY.useNio(); RABBITMQ_CONNECTION_FACTORY.setNioParams(nioParams); RABBITMQ_CONNECTION_FACTORY.setConnectionTimeout(VALUE_CONNECTION_TIMEOUT_MS); RABBITMQ_CONNECTION_FACTORY.setChannelRpcTimeout(VALUE_RPC_CALL_TIMEOUT_MS); RABBITMQ_CONNECTION_FACTORY.setHandshakeTimeout(VALUE_HANDSHAKE_CONNECTION_TIMEOUT_MS); ExecutorService shutdownExecutor = Executors.newSingleThreadExecutor(); RABBITMQ_CONNECTION_FACTORY.setShutdownExecutor(shutdownExecutor); RABBITMQ_CONNECTION_FACTORY.setShutdownTimeout(VALUE_SHUTDOWN_TIMEOUT_MS); RABBITMQ_CONNECTION_FACTORY.setRequestedHeartbeat(VALUE_REQUESTED_HEART_BEAT); RABBITMQ_CONNECTION_FACTORY.setAutomaticRecoveryEnabled(VALUE_AUTOMATIC_RECOVERY); RABBITMQ_CONNECTION_FACTORY.setTopologyRecoveryEnabled(VALUE_AUTOMATIC_EXCHANGE_RECOVERY); RABBITMQ_CONNECTION_FACTORY.setNetworkRecoveryInterval(VALUE_AUTOMATIC_RECOVERY_NETWORK_DELAY_MS); RABBITMQ_CONNECTION_FACTORY.setVirtualHost(this.virtualHost); RABBITMQ_CONNECTION_FACTORY.setSocketConfigurator(new DefaultSocketConfigurator() { @Override public void configure(Socket socket) throws IOException { socket.setTcpNoDelay(VALUE_DONT_USE_NAGLE); socket.setReceiveBufferSize(VALUE_SET_WRITE_BUFFER_SIZE); socket.setSendBufferSize(VALUE_SET_SEND_BUFFER_SIZE); socket.setPerformancePreferences(0, 2, 1); socket.setReuseAddress(true); socket.setKeepAlive(VALUE_TCP_KEELALIVE); socket.setSoLinger(true, 1000); } }); }
/** * Support for Java non-blocking IO * * @param nioParams The NIO mode can be configured through the NioParams class */ public ConnectionOptions withNioParams(NioParams nioParams) { this.nioParams = nioParams; factory.setNioParams(Assert.notNull(nioParams, "nioParams")); factory.useNio(); return this; }
public NioParams getNioParams() { return nioParams; }
/** * Return NioParams object. * @see #withNioParams(NioParams) * @see #withNio() */ public NioParams getNioParams() { return nioParams; }