Search in sources :

Example 1 with BlockingQueueNioQueue

use of com.rabbitmq.client.impl.nio.BlockingQueueNioQueue in project rabbitmq-java-client by rabbitmq.

the class JavaNioTest method customWriteQueue.

@Test
public void customWriteQueue() throws Exception {
    ConnectionFactory cf = new ConnectionFactory();
    cf.useNio();
    AtomicInteger count = new AtomicInteger(0);
    cf.setNioParams(new NioParams().setWriteQueueFactory(ctx -> {
        count.incrementAndGet();
        return new BlockingQueueNioQueue(new LinkedBlockingQueue<>(ctx.getNioParams().getWriteQueueCapacity()), ctx.getNioParams().getWriteEnqueuingTimeoutInMs());
    }));
    try (Connection c = cf.newConnection()) {
        sendAndVerifyMessage(c, 100);
    }
    assertEquals(1, count.get());
}
Also used : BlockingQueueNioQueue(com.rabbitmq.client.impl.nio.BlockingQueueNioQueue) java.util.concurrent(java.util.concurrent) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert.assertTrue(org.junit.Assert.assertTrue) com.rabbitmq.client(com.rabbitmq.client) Test(org.junit.Test) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer) List(java.util.List) DefaultByteBufferFactory(com.rabbitmq.client.impl.nio.DefaultByteBufferFactory) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) After(org.junit.After) Condition(org.assertj.core.api.Condition) NioParams(com.rabbitmq.client.impl.nio.NioParams) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) BlockingQueueNioQueue(com.rabbitmq.client.impl.nio.BlockingQueueNioQueue) NioParams(com.rabbitmq.client.impl.nio.NioParams) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.Test)

Aggregations

com.rabbitmq.client (com.rabbitmq.client)1 BlockingQueueNioQueue (com.rabbitmq.client.impl.nio.BlockingQueueNioQueue)1 DefaultByteBufferFactory (com.rabbitmq.client.impl.nio.DefaultByteBufferFactory)1 NioParams (com.rabbitmq.client.impl.nio.NioParams)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 List (java.util.List)1 java.util.concurrent (java.util.concurrent)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Condition (org.assertj.core.api.Condition)1 After (org.junit.After)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 Test (org.junit.Test)1