dnsquarkusrest-clientquarkus-rest-client

Quarkus RestClient DNS failover on multiple A type IP addresses?


I am using Quarkus RestClient and I encountered some problems. I have an URL, which is internally resolved to 4 different IP addresses (data and IP addresses are pseudonymized in this example):

[user@server]$ dig service.example.com

;; ANSWER SECTION:
service.example.com.    740 IN  CNAME   service-example-com.some-internal-resolution.com.
service-example-com.some-internal-resolution.com. 290 IN A  300.300.351.76
service-example-com.some-internal-resolution.com. 290 IN A  300.300.350.1
service-example-com.some-internal-resolution.com. 290 IN A  300.300.349.76
service-example-com.some-internal-resolution.com. 290 IN A  300.300.348.1

It seems to me that the Quarkus RestClient only fetches the first IP address, because the problem is, when this first IP address is not reachable, I get a connection timeout, although the other ones are reachable, so I think that this is a problem with the RestClient?

Is there a way to bypass this behaviour so the RestClient tries the other IP addresses as well if the first one is not reachable?


Solution

  • That's the expected behavior. To do what you want, you need to use stork (the service discovery framework of Quarkus) - https://smallrye.io/smallrye-stork/1.3.1/service-discovery/dns/

    And then:

    quarkus.stork.my-service.service-discovery.type=dns
    

    and your rest client would use the stork://my-service URL.