Class NioParams
- java.lang.Object
- 
- com.rabbitmq.client.impl.nio.NioParams
 
- 
 public class NioParams extends Object Parameters used to configure the NIO mode of aConnectionFactory.- Since:
- 4.0.0
 
- 
- 
Method Summary
 
- 
- 
- 
Constructor Detail- 
NioParamspublic NioParams() 
 - 
NioParamspublic NioParams(NioParams nioParams) 
 
- 
 - 
Method Detail- 
enableHostnameVerificationpublic NioParams enableHostnameVerification() Enable server hostname verification for TLS connections.- Returns:
- this NioParamsinstance
- See Also:
- setSslEngineConfigurator(SslEngineConfigurator),- SslEngineConfigurators.ENABLE_HOSTNAME_VERIFICATION
 
 - 
getReadByteBufferSizepublic int getReadByteBufferSize() 
 - 
setReadByteBufferSizepublic NioParams setReadByteBufferSize(int readByteBufferSize) Sets the size in byte of the readByteBufferused in the NIO loop. Default is 32768.This parameter isn't used when using SSL/TLS, where ByteBuffersize is set up according to theSSLSessionpacket size.- Parameters:
- readByteBufferSize- size of the- ByteBufferfor inbound data
- Returns:
- this NioParamsinstance
 
 - 
getWriteByteBufferSizepublic int getWriteByteBufferSize() 
 - 
setWriteByteBufferSizepublic NioParams setWriteByteBufferSize(int writeByteBufferSize) Sets the size in byte of the writeByteBufferused in the NIO loop. Default is 32768.This parameter isn't used when using SSL/TLS, where ByteBuffersize is set up according to theSSLSessionpacket size.- Parameters:
- writeByteBufferSize- size of the- ByteBufferused for outbound data
- Returns:
- this NioParamsinstance
 
 - 
getNbIoThreadspublic int getNbIoThreads() 
 - 
setNbIoThreadspublic NioParams setNbIoThreads(int nbIoThreads) Sets the max number of threads/tasks used for NIO. Default is 1. Set this number according to the number of simultaneous connections and their activity. Threads/tasks are created as necessary (e.g. with 10 threads, when 10 connections have been created). Once a connection is created, it's assigned to a thread/task and all its IO activity is handled by this thread/task.When idle for a few seconds (i.e. without any connection to perform IO for), a thread/task stops and is recreated if necessary. - Parameters:
- nbIoThreads-
- Returns:
- this NioParamsinstance
 
 - 
getWriteEnqueuingTimeoutInMspublic int getWriteEnqueuingTimeoutInMs() 
 - 
setWriteEnqueuingTimeoutInMspublic NioParams setWriteEnqueuingTimeoutInMs(int writeEnqueuingTimeoutInMs) Sets the timeout for queuing outbound frames. Default is 10,000 ms. Every requests to the server is divided into frames that are then queued in aBlockingQueuebefore being sent on the network by a IO thread.If the IO thread cannot cope with the frames dispatch, the BlockingQueuegets filled up and blocks (blocking the calling thread by the same occasion). This timeout is the time theBlockingQueuewill wait before rejecting the outbound frame. The calling thread will then received an exception.The appropriate value depends on the application scenarios: rate of outbound data (published messages, acknowledgment, etc), network speed... - Parameters:
- writeEnqueuingTimeoutInMs-
- Returns:
- this NioParamsinstance
- See Also:
- setWriteQueueCapacity(int)
 
 - 
getNioExecutorpublic ExecutorService getNioExecutor() 
 - 
setNioExecutorpublic NioParams setNioExecutor(ExecutorService nioExecutor) Sets theExecutorServiceto use for NIO threads/tasks. Default is to use the thread factory.The ExecutorServiceshould be able to run the number of requested IO threads, plus a few more, as it's also used to dispatch the shutdown of connections.Connection shutdown can also be handled by a dedicated ExecutorService, seesetConnectionShutdownExecutor(ExecutorService).It's developer's responsibility to shut down the executor when it is no longer needed. The thread factory isn't used if an executor service is set up. - Parameters:
- nioExecutor-- ExecutorServiceused for IO threads and connection shutdown
- Returns:
- this NioParamsinstance
- See Also:
- setNbIoThreads(int),- setThreadFactory(ThreadFactory),- setConnectionShutdownExecutor(ExecutorService)
 
 - 
getThreadFactorypublic ThreadFactory getThreadFactory() 
 - 
setThreadFactorypublic NioParams setThreadFactory(ThreadFactory threadFactory) Sets theThreadFactoryto use for NIO threads/tasks. Default is to use theConnectionFactory'sThreadFactory.The ThreadFactoryis used to spawn the IO threads and dispatch the shutdown of connections.- Parameters:
- threadFactory-- ThreadFactoryused for IO threads and connection shutdown
- Returns:
- this NioParamsinstance
- See Also:
- setNbIoThreads(int),- setNioExecutor(ExecutorService)
 
 - 
getWriteQueueCapacitypublic int getWriteQueueCapacity() 
 - 
setWriteQueueCapacitypublic NioParams setWriteQueueCapacity(int writeQueueCapacity) Set the capacity of the queue used for outbound frames. Default capacity is 10,000.- Parameters:
- writeQueueCapacity-
- Returns:
- this NioParamsinstance
- See Also:
- setWriteEnqueuingTimeoutInMs(int)
 
 - 
getSocketChannelConfiguratorpublic SocketChannelConfigurator getSocketChannelConfigurator() 
 - 
setSocketChannelConfiguratorpublic void setSocketChannelConfigurator(SocketChannelConfigurator configurator) Set theSocketChannelconfigurator. This gets a chance to "configure" a socket channel before it has been opened. The default implementation disables Nagle's algorithm.- Parameters:
- configurator- the configurator to use
 
 - 
getSslEngineConfiguratorpublic SslEngineConfigurator getSslEngineConfigurator() 
 - 
setSslEngineConfiguratorpublic void setSslEngineConfigurator(SslEngineConfigurator configurator) Set theSSLEngineconfigurator. This gets a change to "configure" the SSL engine before the connection has been opened. This can be used e.g. to setSSLParameters. The default implementation doesn't do anything.- Parameters:
- configurator- the configurator to use
 
 - 
getConnectionShutdownExecutorpublic ExecutorService getConnectionShutdownExecutor() 
 - 
setConnectionShutdownExecutorpublic NioParams setConnectionShutdownExecutor(ExecutorService connectionShutdownExecutor) Set theExecutorServiceused for connection shutdown. If not set, falls back to the NIO executor and then the thread factory. This executor service is useful when strict control of the number of threads is necessary, the application can experience the closing of several connections at once, and automatic recovery is enabled. In such cases, the connection recovery can take place in the same pool of threads as the NIO operations, which can create deadlocks (all the threads of the pool are busy recovering, and there's no thread left for NIO, so connections never recover).Note it's developer's responsibility to shut down the executor when it is no longer needed. Using the thread factory for such scenarios avoid the deadlocks, at the price of potentially creating many short-lived threads in case of massive connection lost. With both the NIO and connection shutdown executor services set and configured accordingly, the application can control reliably the number of threads used. - Parameters:
- connectionShutdownExecutor- the executor service to use
- Returns:
- this NioParamsinstance
- Since:
- 4.8.0
- See Also:
- setNioExecutor(ExecutorService)
 
 - 
setByteBufferFactorypublic NioParams setByteBufferFactory(ByteBufferFactory byteBufferFactory) Set the factory to createByteBuffers.The default implementation creates heap-based ByteBuffers.- Parameters:
- byteBufferFactory- the factory to use
- Returns:
- this NioParamsinstance
- Since:
- 4.9.0
- See Also:
- ByteBufferFactory,- DefaultByteBufferFactory
 
 - 
getByteBufferFactorypublic ByteBufferFactory getByteBufferFactory() 
 - 
setWriteQueueFactorypublic NioParams setWriteQueueFactory(NioQueueFactory writeQueueFactory) Set the factory to createNioQueues.The default uses a ArrayBlockingQueue.
 - 
getWriteQueueFactorypublic NioQueueFactory getWriteQueueFactory() 
 
- 
 
-