Skip to content

Commit 1a41290

Browse files
authored
Spring App Config Auto Failover doc (#39375)
* Updated doc, added check and log message * Update README.md
1 parent abcf8c1 commit 1a41290

File tree

2 files changed

+7
-1
lines changed
  • sdk/spring
    • spring-cloud-azure-appconfiguration-config/src/main/java/com/azure/spring/cloud/appconfiguration/config/implementation/autofailover
    • spring-cloud-azure-starter-appconfiguration-config

2 files changed

+7
-1
lines changed

sdk/spring/spring-cloud-azure-appconfiguration-config/src/main/java/com/azure/spring/cloud/appconfiguration/config/implementation/autofailover/ReplicaLookUp.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import javax.naming.directory.Attribute;
1919
import javax.naming.directory.InitialDirContext;
2020

21+
import org.slf4j.Logger;
22+
import org.slf4j.LoggerFactory;
2123
import org.springframework.scheduling.annotation.Async;
2224
import org.springframework.stereotype.Component;
2325
import org.springframework.util.StringUtils;
@@ -29,6 +31,8 @@
2931
@Component
3032
public class ReplicaLookUp {
3133

34+
private static final Logger LOGGER = LoggerFactory.getLogger(ReplicaLookUp.class);
35+
3236
private static final String ORIGIN_PREFIX = "dns:/_origin._tcp.";
3337

3438
private static final String REPLICA_PREFIX_ALT = "dns:/_alt";
@@ -63,7 +67,7 @@ public ReplicaLookUp(AppConfigurationProperties properties) throws NamingExcepti
6367
public void updateAutoFailoverEndpoints() {
6468
if (semaphore.tryAcquire()) {
6569
for (ConfigStore configStore : properties.getStores()) {
66-
if (!configStore.isEnabled()) {
70+
if (!configStore.isEnabled() || !configStore.isReplicaDiscoveryEnabled()) {
6771
continue;
6872
}
6973
String mainEndpoint = configStore.getEndpoint();
@@ -88,6 +92,7 @@ public void updateAutoFailoverEndpoints() {
8892
records.put(mainEndpoint, srvRecords);
8993
wait.put(mainEndpoint, Instant.now().plus(FALLBACK_CLIENT_REFRESH_EXPIRED_INTERVAL));
9094
} catch (AppConfigurationReplicaException e) {
95+
LOGGER.warn("Failed to finde replicas due to: " + e.getMessage());
9196
wait.put(mainEndpoint, Instant.now().plus(MINIMAL_CLIENT_REFRESH_INTERVAL));
9297
}
9398

sdk/spring/spring-cloud-azure-starter-appconfiguration-config/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ spring.cloud.azure.appconfiguration.stores[0].selects[0].key-filter | The key pa
6464
spring.cloud.azure.appconfiguration.stores[0].selects[0].label-filter | The label used to indicate which configuration(s) will be loaded. | No | `${spring.profiles.active}` or if null `\0`
6565
spring.cloud.azure.appconfiguration.stores[0].selects[0].snapshot-name | The snapshot name used to indicate which configuration(s) will be loaded. | No | null
6666
spring.cloud.azure.appconfiguration.stores[0].trim-key-prefix[0] | The prefix that will be trimmed from the key when the configuration is loaded. | No | null, unless using key-filter, then it is the key-filter
67+
spring.cloud.azure.appconfiguration.stores[0].replicaDiscoveryEnabled | Enables periodic checking if new replicas of the store have been created. And found stores will be added to the bottom of the list of endpoints used in cases where the store can't be reached. | No | true
6768

6869
Configuration Store Authentication
6970

0 commit comments

Comments
 (0)