Package org.apache.camel.health
Interface HealthCheckRegistry
-
- All Superinterfaces:
AutoCloseable,CamelContextAware,HasId,IdAware,Service,StaticService
public interface HealthCheckRegistry extends CamelContextAware, StaticService, IdAware
A registry for health checks.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static HealthCheckRegistryget(CamelContext context)Returns an optionalHealthCheckRegistry, by default no registry is present, and it must be explicit activated.default Optional<HealthCheck>getCheck(String id)Returns the check identified by the givenidif available.default Collection<String>getCheckIDs()A collection of health check IDs.StringgetExcludePattern()Pattern to exclude health checks from being invoked by Camel when checking healths.StringgetExposureLevel()The exposure levelHealthCheck.StategetInitialState()The initial state of health-checks.Optional<HealthCheckRepository>getRepository(String id)Returns the repository identified by the givenidif available.booleanisEnabled()Whether Health Check is enabled globallybooleanisExcluded(HealthCheck healthCheck)Whether the given health check has been excludedvoidloadHealthChecks()Loads custom health checks by scanning classpath.booleanregister(Object obj)Registers aHealthCheckorHealthCheckRepository.ObjectresolveById(String id)ResolvesHealthCheckorHealthCheckRepositoryby id.voidsetEnabled(boolean enabled)Whether Health Check is enabled globallyvoidsetExcludePattern(String excludePattern)Pattern to exclude health checks from being invoked by Camel when checking healths.voidsetExposureLevel(String exposureLevel)Sets the level of details to exposure as result of invoking health checks.voidsetInitialState(HealthCheck.State initialState)The initial state of health-checks (readiness).Stream<HealthCheck>stream()Returns a sequentialStreamwith the knownHealthCheckas its source.booleanunregister(Object obj)Unregisters aHealthCheckorHealthCheckRepository.-
Methods inherited from interface org.apache.camel.CamelContextAware
getCamelContext, setCamelContext
-
Methods inherited from interface org.apache.camel.spi.IdAware
setGeneratedId, setId
-
-
-
-
Field Detail
-
NAME
static final String NAME
Service factory name.- See Also:
- Constant Field Values
-
FACTORY
static final String FACTORY
Service factory key.- See Also:
- Constant Field Values
-
-
Method Detail
-
isEnabled
boolean isEnabled()
Whether Health Check is enabled globally
-
setEnabled
void setEnabled(boolean enabled)
Whether Health Check is enabled globally
-
resolveById
Object resolveById(String id)
ResolvesHealthCheckorHealthCheckRepositoryby id. Will first lookup in thisHealthCheckRegistryand thenRegistry, and lastly do classpath scanning viaServiceFactory. The classpath scanning is attempted first with id-health-check or id-health-check-repository as the key, and then with id as fallback if not found the first time.- Returns:
- either
HealthCheckorHealthCheckRepository, or null if none found.
-
register
boolean register(Object obj)
Registers aHealthCheckorHealthCheckRepository.
-
unregister
boolean unregister(Object obj)
Unregisters aHealthCheckorHealthCheckRepository.
-
getCheckIDs
default Collection<String> getCheckIDs()
A collection of health check IDs.
-
getCheck
default Optional<HealthCheck> getCheck(String id)
Returns the check identified by the givenidif available.
-
getRepository
Optional<HealthCheckRepository> getRepository(String id)
Returns the repository identified by the givenidif available.
-
get
static HealthCheckRegistry get(CamelContext context)
Returns an optionalHealthCheckRegistry, by default no registry is present, and it must be explicit activated. Components can register/unregister health checks in response to life-cycle events (i.e. start/stop). This registry is not used by the camel context, but it is up to the implementation to properly use it, such as: - a RouteController could use the registry to decide to restart a route with failing health checks - spring boot could integrate such checks within its health endpoint or make it available only as separate endpoint.
-
stream
Stream<HealthCheck> stream()
Returns a sequentialStreamwith the knownHealthCheckas its source.
-
loadHealthChecks
void loadHealthChecks()
Loads custom health checks by scanning classpath.
-
getExcludePattern
String getExcludePattern()
Pattern to exclude health checks from being invoked by Camel when checking healths. Multiple patterns can be separated by comma.
-
setExcludePattern
void setExcludePattern(String excludePattern)
Pattern to exclude health checks from being invoked by Camel when checking healths. Multiple patterns can be separated by comma.
-
isExcluded
boolean isExcluded(HealthCheck healthCheck)
Whether the given health check has been excluded
-
setExposureLevel
void setExposureLevel(String exposureLevel)
Sets the level of details to exposure as result of invoking health checks. There are the following levels: full, default, oneline The full level will include all details and status from all the invoked health checks. The default level will report UP if everything is okay, and only include detailed information for health checks that was DOWN. The oneline level will only report either UP or DOWN.
-
getExposureLevel
String getExposureLevel()
The exposure level
-
setInitialState
void setInitialState(HealthCheck.State initialState)
The initial state of health-checks (readiness). There are the following states: UP, DOWN, UNKNOWN. By default, the state is DOWN, is regarded as being pessimistic/careful. This means that the overall health checks may report as DOWN during startup and then only if everything is up and running flip to being UP. Setting the initial state to UP, is regarded as being optimistic. This means that the overall health checks may report as UP during startup and then if a consumer or other service is in fact un-healthy, then the health-checks can flip being DOWN. Setting the state to UNKNOWN means that some health-check would be reported in unknown state, especially during early bootstrap where a consumer may not be fully initialized or validated a connection to a remote system. This option allows to pre-configure the state for different modes.
-
getInitialState
HealthCheck.State getInitialState()
The initial state of health-checks.
-
-