Search in sources :

Example 1 with DefaultSocketConfigurator

use of com.rabbitmq.client.DefaultSocketConfigurator in project rabbitmq-java-client by rabbitmq.

the class NoAutoRecoveryWhenTcpWindowIsFullTest method setUp.

@Before
public void setUp() throws Exception {
    // we need several threads to publish, dispatch deliveries, handle RPC responses, etc.
    executorService = Executors.newFixedThreadPool(10);
    final ConnectionFactory factory = TestUtils.connectionFactory();
    factory.setSocketConfigurator(new DefaultSocketConfigurator() {

        /* default value on Linux */
        int DEFAULT_RECEIVE_BUFFER_SIZE = 43690;

        @Override
        public void configure(Socket socket) throws IOException {
            super.configure(socket);
            socket.setReceiveBufferSize(DEFAULT_RECEIVE_BUFFER_SIZE);
        }
    });
    factory.setAutomaticRecoveryEnabled(true);
    factory.setTopologyRecoveryEnabled(true);
    // we try to set the lower values for closing timeouts, etc.
    // this makes the test execute faster.
    factory.setRequestedHeartbeat(5);
    factory.setSharedExecutor(executorService);
    // we need the shutdown executor: channel shutting down depends on the work pool,
    // which is full. Channel shutting down will time out with the shutdown executor.
    factory.setShutdownExecutor(executorService);
    factory.setNetworkRecoveryInterval(2000);
    if (TestUtils.USE_NIO) {
        factory.setWorkPoolTimeout(10 * 1000);
        factory.setNioParams(new NioParams().setWriteQueueCapacity(10 * 1000 * 1000).setNbIoThreads(4));
    }
    producingConnection = (AutorecoveringConnection) factory.newConnection("Producer Connection");
    producingChannel = (AutorecoveringChannel) producingConnection.createChannel();
    consumingConnection = (AutorecoveringConnection) factory.newConnection("Consuming Connection");
    consumingChannel = (AutorecoveringChannel) consumingConnection.createChannel();
    consumerOkLatch = new CountDownLatch(2);
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) NioParams(com.rabbitmq.client.impl.nio.NioParams) IOException(java.io.IOException) CountDownLatch(java.util.concurrent.CountDownLatch) DefaultSocketConfigurator(com.rabbitmq.client.DefaultSocketConfigurator) Socket(java.net.Socket) Before(org.junit.Before)

Aggregations

ConnectionFactory (com.rabbitmq.client.ConnectionFactory)1 DefaultSocketConfigurator (com.rabbitmq.client.DefaultSocketConfigurator)1 NioParams (com.rabbitmq.client.impl.nio.NioParams)1 IOException (java.io.IOException)1 Socket (java.net.Socket)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Before (org.junit.Before)1