Package com.rabbitmq.client
Class DnsSrvRecordAddressResolver
java.lang.Object
com.rabbitmq.client.DnsSrvRecordAddressResolver
- All Implemented Interfaces:
AddressResolver
AddressResolver
that resolves addresses against a DNS SRV request.
SRV records contain the hostname and the port for a given service.
They also support priorities, to give precedence to a given host
over other hosts.
Note the hosts returned by the SRV query must be resolvable by
the DNS servers of the underlying platform (or the default ones
specified for this Java process). This class does not issue a
query for A records after the SRV query.
This implementation returns the highest-priority records first.
This behavior can be changed by overriding the sort
method.
This implementation uses internally the com.sun.jndi.dns.DnsContextFactory
class for the DNS query.
The first returned address is used when automatic recovery is NOT enabled
at the ConnectionFactory
level.
When automatic recovery is enabled, a random address will be picked up
from the returned list of Address
es.-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionDnsSrvRecordAddressResolver
(String service) DnsSrvRecordAddressResolver
(String service, String dnsUrls) -
Method Summary
Modifier and TypeMethodDescriptionGet the potentialAddress
es to connect to.protected List
<DnsSrvRecordAddressResolver.SrvRecord> lookupSrvRecords
(String service, String dnsUrls) protected DnsSrvRecordAddressResolver.SrvRecord
mapSrvRecord
(String srvResult) protected List
<DnsSrvRecordAddressResolver.SrvRecord> sort
(List<DnsSrvRecordAddressResolver.SrvRecord> records) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.rabbitmq.client.AddressResolver
maybeShuffle
-
Constructor Details
-
DnsSrvRecordAddressResolver
-
DnsSrvRecordAddressResolver
-
-
Method Details
-
getAddresses
Description copied from interface:AddressResolver
Get the potentialAddress
es to connect to.- Specified by:
getAddresses
in interfaceAddressResolver
- Returns:
- candidate
Address
es - Throws:
IOException
- if it encounters a problem
-
lookupSrvRecords
protected List<DnsSrvRecordAddressResolver.SrvRecord> lookupSrvRecords(String service, String dnsUrls) throws IOException - Throws:
IOException
-
mapSrvRecord
-
sort
protected List<DnsSrvRecordAddressResolver.SrvRecord> sort(List<DnsSrvRecordAddressResolver.SrvRecord> records)
-