CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-de-codecentric--spring-boot-admin-starter-client

Spring Boot starter that auto-configures a client application to register with Spring Boot Admin server for centralized monitoring and management

Pending
Overview
Eval results
Files

application-registration.mddocs/

Application Registration

Application registration provides programmatic control over how and when a Spring Boot application registers itself with Spring Boot Admin servers. While automatic registration is the default behavior, you can manually control the registration process for advanced use cases.

Core Interfaces

ApplicationRegistrator

public interface ApplicationRegistrator {
    /**
     * Registers the client application at spring-boot-admin-server.
     * @return true if successful registration on at least one admin server
     */
    boolean register();
    
    /**
     * Tries to deregister currently registered application
     */
    void deregister();
    
    /**
     * @return the id of this client as given by the admin server. 
     * Returns null if the client has not registered against the admin server yet.
     */
    String getRegisteredId();
}

Application Model

public class Application {
    // Create a new application builder
    public static Builder create(String name);
    
    // Application properties (all immutable)
    public String getName();
    public String getManagementUrl();
    public String getHealthUrl();
    public String getServiceUrl();
    public Map<String, String> getMetadata();
    
    public static class Builder {
        public Builder name(String name);
        public Builder managementUrl(String managementUrl);
        public Builder healthUrl(String healthUrl);
        public Builder serviceUrl(String serviceUrl);
        public Builder metadata(String key, String value);
        public Builder metadata(Map<String, String> metadata);
        public Application build();
    }
}

ApplicationFactory

public interface ApplicationFactory {
    /**
     * Create an Application instance from current configuration
     */
    Application createApplication();
}

Registration Implementations

DefaultApplicationRegistrator

public class DefaultApplicationRegistrator implements ApplicationRegistrator {
    public DefaultApplicationRegistrator(
        ApplicationFactory applicationFactory,
        RegistrationClient registrationClient,
        String[] adminUrl,
        boolean registerOnce
    );
}

RegistrationApplicationListener

public class RegistrationApplicationListener {
    public void setAutoRegister(boolean autoRegister);
    public void setAutoDeregister(boolean autoDeregister);
    public void setRegisterPeriod(Duration registerPeriod);
}

HTTP Client Support

RegistrationClient Interface

public interface RegistrationClient {
    /**
     * Register application with admin server
     * @param adminUrl The admin server URL
     * @param self The application to register
     * @return Registration ID from server
     */
    String register(String adminUrl, Application self);
    
    /**
     * Deregister application from admin server
     * @param adminUrl The admin server URL  
     * @param id The registration ID
     */
    void deregister(String adminUrl, String id);
}

Servlet Stack Implementation

public class BlockingRegistrationClient implements RegistrationClient {
    public BlockingRegistrationClient(RestTemplate restTemplate);
}

Reactive Stack Implementation

public class ReactiveRegistrationClient implements RegistrationClient {
    public ReactiveRegistrationClient(WebClient webClient, Duration timeout);
}

Manual Registration Example

@Component
public class CustomRegistrationService {
    
    private final ApplicationRegistrator registrator;
    
    public CustomRegistrationService(ApplicationRegistrator registrator) {
        this.registrator = registrator;
    }
    
    public void registerWithAdminServer() {
        boolean success = registrator.register();
        if (success) {
            String registrationId = registrator.getRegisteredId();
            log.info("Successfully registered with ID: {}", registrationId);
        } else {
            log.warn("Failed to register with admin server");
        }
    }
    
    public void unregisterFromAdminServer() {
        registrator.deregister();
        log.info("Deregistered from admin server");
    }
}

Custom Application Factory

@Component
public class CustomApplicationFactory implements ApplicationFactory {
    
    private final InstanceProperties instanceProperties;
    
    public CustomApplicationFactory(InstanceProperties instanceProperties) {
        this.instanceProperties = instanceProperties;
    }
    
    @Override
    public Application createApplication() {
        return Application.create(instanceProperties.getName())
            .serviceUrl("https://my-service.example.com")
            .managementUrl("https://my-service.example.com/actuator")
            .healthUrl("https://my-service.example.com/actuator/health")
            .metadata("custom-tag", "custom-value")
            .metadata("build-time", Instant.now().toString())
            .build();
    }
}

Conditional Registration

@Component
@ConditionalOnProperty(value = "app.admin.registration.enabled", havingValue = "true")
public class ConditionalRegistrationService {
    
    private final ApplicationRegistrator registrator;
    private final Environment environment;
    
    public ConditionalRegistrationService(
            ApplicationRegistrator registrator, 
            Environment environment) {
        this.registrator = registrator;
        this.environment = environment;
    }
    
    @EventListener(ApplicationReadyEvent.class)
    public void onApplicationReady() {
        if (shouldRegister()) {
            registrator.register();
        }
    }
    
    @EventListener(ContextClosedEvent.class)
    public void onApplicationClosed() {
        registrator.deregister();
    }
    
    private boolean shouldRegister() {
        String[] profiles = environment.getActiveProfiles();
        return Arrays.asList(profiles).contains("production");
    }
}

Disabling Automatic Registration

To take full manual control, disable automatic registration:

# Disable automatic registration
spring.boot.admin.client.auto-registration=false
spring.boot.admin.client.auto-deregistration=false

Then implement your own registration logic as shown in the examples above.

Registration Lifecycle

  1. Application Startup: If auto-registration is enabled, the application automatically registers
  2. Periodic Updates: Registration is renewed based on the configured period
  3. Health Monitoring: The admin server monitors the registered health URL
  4. Application Shutdown: If auto-deregistration is enabled, the application deregisters

Error Handling

Registration failures are logged but do not prevent application startup. The client will continue to retry registration based on the configured period until successful or the application shuts down.

Install with Tessl CLI

npx tessl i tessl/maven-de-codecentric--spring-boot-admin-starter-client

docs

application-registration.md

client-configuration.md

cloud-platform-integration.md

index.md

instance-configuration.md

metadata-management.md

tile.json