Package com.rabbitmq.client
Class DnsSrvRecordAddressResolver
- java.lang.Object
-
- com.rabbitmq.client.DnsSrvRecordAddressResolver
-
- All Implemented Interfaces:
AddressResolver
public class DnsSrvRecordAddressResolver extends java.lang.Object implements AddressResolver
AddressResolverthat 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 thesortmethod. This implementation uses internally thecom.sun.jndi.dns.DnsContextFactoryclass for the DNS query. The first returned address is used when automatic recovery is NOT enabled at theConnectionFactorylevel. When automatic recovery is enabled, a random address will be picked up from the returned list ofAddresses.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDnsSrvRecordAddressResolver.SrvRecord
-
Constructor Summary
Constructors Constructor Description DnsSrvRecordAddressResolver(java.lang.String service)DnsSrvRecordAddressResolver(java.lang.String service, java.lang.String dnsUrls)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Address>getAddresses()Get the potentialAddresses to connect to.protected java.util.List<DnsSrvRecordAddressResolver.SrvRecord>lookupSrvRecords(java.lang.String service, java.lang.String dnsUrls)protected DnsSrvRecordAddressResolver.SrvRecordmapSrvRecord(java.lang.String srvResult)protected java.util.List<DnsSrvRecordAddressResolver.SrvRecord>sort(java.util.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
-
-
-
-
Field Detail
-
service
private final java.lang.String service
the SRV service information. e.g. _sip._tcp.example.com or rabbitmq.service.consul
-
dnsUrls
private final java.lang.String dnsUrls
URLs of the DNS servers. e.g. dns://server1.example.com/example.com Default todns:, that is the DNS server of the underlying platform.
-
-
Method Detail
-
getAddresses
public java.util.List<Address> getAddresses() throws java.io.IOException
Description copied from interface:AddressResolverGet the potentialAddresses to connect to.- Specified by:
getAddressesin interfaceAddressResolver- Returns:
- candidate
Addresses - Throws:
java.io.IOException- if it encounters a problem
-
lookupSrvRecords
protected java.util.List<DnsSrvRecordAddressResolver.SrvRecord> lookupSrvRecords(java.lang.String service, java.lang.String dnsUrls) throws java.io.IOException
- Throws:
java.io.IOException
-
mapSrvRecord
protected DnsSrvRecordAddressResolver.SrvRecord mapSrvRecord(java.lang.String srvResult)
-
sort
protected java.util.List<DnsSrvRecordAddressResolver.SrvRecord> sort(java.util.List<DnsSrvRecordAddressResolver.SrvRecord> records)
-
-