Search in sources :

Example 76 with ConnectionFactory

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

the class ChannelLimitNegotiation method channelMaxLowerThanServerMinimum.

@Test
public void channelMaxLowerThanServerMinimum() throws Exception {
    int n = 64;
    ConnectionFactory cf = TestUtils.connectionFactory();
    cf.setRequestedChannelMax(n);
    try (Connection conn = cf.newConnection()) {
        assertEquals(n, conn.getChannelMax());
    }
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) AMQConnection(com.rabbitmq.client.impl.AMQConnection) Connection(com.rabbitmq.client.Connection) AutorecoveringConnection(com.rabbitmq.client.impl.recovery.AutorecoveringConnection) Test(org.junit.Test)

Example 77 with ConnectionFactory

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

the class Heartbeat method newConnectionFactory.

@Override
protected ConnectionFactory newConnectionFactory() {
    ConnectionFactory cf = super.newConnectionFactory();
    cf.setRequestedHeartbeat(1);
    return cf;
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory)

Example 78 with ConnectionFactory

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

the class Metrics method createConnectionFactory.

private static ConnectionFactory createConnectionFactory() {
    ConnectionFactory connectionFactory = TestUtils.connectionFactory();
    connectionFactory.setAutomaticRecoveryEnabled(false);
    return connectionFactory;
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory)

Example 79 with ConnectionFactory

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

the class ExchangeDeclare method exchangeDeclaredWithEnumerationEquivalentOnRecoverableConnection.

@Test
public void exchangeDeclaredWithEnumerationEquivalentOnRecoverableConnection() throws IOException, TimeoutException, InterruptedException {
    ConnectionFactory connectionFactory = TestUtils.connectionFactory();
    connectionFactory.setAutomaticRecoveryEnabled(true);
    connectionFactory.setTopologyRecoveryEnabled(false);
    Connection c = connectionFactory.newConnection();
    try {
        doTestExchangeDeclaredWithEnumerationEquivalent(c.createChannel());
    } finally {
        c.abort();
    }
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) Connection(com.rabbitmq.client.Connection) Test(org.junit.Test)

Example 80 with ConnectionFactory

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

the class FrameMax method rejectLargeFramesDuringConnectionNegotiation.

/* server should reject frames larger than AMQP.FRAME_MIN_SIZE
     * during connection negotiation */
@Test
public void rejectLargeFramesDuringConnectionNegotiation() throws IOException, TimeoutException {
    ConnectionFactory cf = TestUtils.connectionFactory();
    cf.getClientProperties().put("too_long", LongStringHelper.asLongString(new byte[AMQP.FRAME_MIN_SIZE]));
    try {
        cf.newConnection();
        fail("Expected exception during connection negotiation");
    } catch (IOException e) {
    }
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

ConnectionFactory (com.rabbitmq.client.ConnectionFactory)188 Connection (com.rabbitmq.client.Connection)87 Test (org.junit.Test)73 Channel (com.rabbitmq.client.Channel)63 IOException (java.io.IOException)53 TimeoutException (java.util.concurrent.TimeoutException)23 DefaultConsumer (com.rabbitmq.client.DefaultConsumer)11 Envelope (com.rabbitmq.client.Envelope)11 SSLContext (javax.net.ssl.SSLContext)11 QueueingConsumer (com.rabbitmq.client.QueueingConsumer)9 HashMap (java.util.HashMap)9 CountDownLatch (java.util.concurrent.CountDownLatch)8 AMQP (com.rabbitmq.client.AMQP)6 Consumer (com.rabbitmq.client.Consumer)6 ShutdownSignalException (com.rabbitmq.client.ShutdownSignalException)6 AMQConnection (com.rabbitmq.client.impl.AMQConnection)6 Address (com.rabbitmq.client.Address)5 NioParams (com.rabbitmq.client.impl.nio.NioParams)4 AutorecoveringConnection (com.rabbitmq.client.impl.recovery.AutorecoveringConnection)4 Path (javax.ws.rs.Path)3