-
Notifications
You must be signed in to change notification settings - Fork 413
Closed
Labels
Milestone
Description
Describe the bug
Setting spring.cloud.zookeeper.discovery.initial-status
to OUT_OF_SERVICE
not working.
Possible fix:
@Bean
@ConditionalOnMissingBean(ZookeeperRegistration.class)
public ServiceInstanceRegistration serviceInstanceRegistration(
ApplicationContext context, ZookeeperDiscoveryProperties properties) {
String appName = context.getEnvironment().getProperty("spring.application.name",
"application");
String host = properties.getInstanceHost();
if (!StringUtils.hasText(host)) {
throw new IllegalStateException("instanceHost must not be empty");
}
// FIX
properties.getMetadata().put(StatusConstants.INSTANCE_STATUS_KEY, properties.getInitialStatus());
ZookeeperInstance zookeeperInstance = new ZookeeperInstance(context.getId(),
appName, properties.getMetadata());
RegistrationBuilder builder = ServiceInstanceRegistration.builder().address(host)
.name(appName).payload(zookeeperInstance)
.uriSpec(properties.getUriSpec());
if (properties.getInstanceSslPort() != null) {
builder.sslPort(properties.getInstanceSslPort());
}
if (properties.getInstanceId() != null) {
builder.id(properties.getInstanceId());
}
// TODO add customizer?
return builder.build();
}