Search in sources :

Example 1 with DnsRecordIpAddressResolver

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

the class DnsRecordIpAddressResolverTests method loopbackInterfaceResolution.

@Test
public void loopbackInterfaceResolution() throws IOException, TimeoutException {
    DnsRecordIpAddressResolver addressResolver = new DnsRecordIpAddressResolver("127.0.0.1");
    ConnectionFactory connectionFactory = newConnectionFactory();
    Connection connection = connectionFactory.newConnection(addressResolver);
    try {
        connection.createChannel();
    } finally {
        connection.abort();
    }
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) DnsRecordIpAddressResolver(com.rabbitmq.client.DnsRecordIpAddressResolver) Connection(com.rabbitmq.client.Connection) Test(org.junit.Test)

Example 2 with DnsRecordIpAddressResolver

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

the class DnsRecordIpAddressResolverTests method localhostResolution.

@Test
public void localhostResolution() throws IOException, TimeoutException {
    DnsRecordIpAddressResolver addressResolver = new DnsRecordIpAddressResolver("localhost");
    ConnectionFactory connectionFactory = newConnectionFactory();
    Connection connection = connectionFactory.newConnection(addressResolver);
    try {
        connection.createChannel();
    } finally {
        connection.abort();
    }
}
Also used : ConnectionFactory(com.rabbitmq.client.ConnectionFactory) DnsRecordIpAddressResolver(com.rabbitmq.client.DnsRecordIpAddressResolver) Connection(com.rabbitmq.client.Connection) Test(org.junit.Test)

Example 3 with DnsRecordIpAddressResolver

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

the class DnsRecordIpAddressResolverTests method resolutionFails.

@Test
public void resolutionFails() throws IOException, TimeoutException {
    DnsRecordIpAddressResolver addressResolver = new DnsRecordIpAddressResolver("afancyandunlikelyhostname");
    try {
        connectionFactory.newConnection(addressResolver);
        fail("The host resolution should have failed");
    } catch (UnknownHostException e) {
    // expected
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) DnsRecordIpAddressResolver(com.rabbitmq.client.DnsRecordIpAddressResolver) Test(org.junit.Test)

Aggregations

DnsRecordIpAddressResolver (com.rabbitmq.client.DnsRecordIpAddressResolver)3 Test (org.junit.Test)3 Connection (com.rabbitmq.client.Connection)2 ConnectionFactory (com.rabbitmq.client.ConnectionFactory)2 UnknownHostException (java.net.UnknownHostException)1