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);
}
Aggregations