Package org.apache.camel.health
Interface HealthCheckRegistry
- All Superinterfaces:
AutoCloseable,CamelContextAware,HasCamelContext,HasId,IdAware,Service,StaticService
A registry for health checks.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic HealthCheckRegistryget(CamelContext context) Returns an optionalHealthCheckRegistry, by default no registry is present, and it must be explicit activated.default Optional<HealthCheck> Returns the check identified by the givenidif available.default Collection<String> A collection of health check IDs.Pattern to exclude health checks from being invoked by Camel when checking healths.The exposure levelThe initial state of health-checks.getRepository(String id) Returns the repository identified by the givenidif available.booleanWhether Health Check is enabled globallybooleanisExcluded(HealthCheck healthCheck) Whether the given health check has been excludedvoidLoads custom health checks by scanning classpath.booleanRegisters aHealthCheckorHealthCheckRepository.resolveById(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()Returns a sequentialStreamwith the knownHealthCheckas its source.booleanunregister(Object obj) Unregisters aHealthCheckorHealthCheckRepository.Methods inherited from interface org.apache.camel.CamelContextAware
setCamelContextMethods inherited from interface org.apache.camel.spi.HasCamelContext
getCamelContextMethods inherited from interface org.apache.camel.spi.IdAware
setGeneratedId, setId
-
Field Details
-
NAME
Service factory name.- See Also:
-
FACTORY
Service factory key.- See Also:
-
-
Method Details
-
isEnabled
boolean isEnabled()Whether Health Check is enabled globally -
setEnabled
void setEnabled(boolean enabled) Whether Health Check is enabled globally -
resolveById
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
Registers aHealthCheckorHealthCheckRepository. -
unregister
Unregisters aHealthCheckorHealthCheckRepository. -
getCheckIDs
A collection of health check IDs. -
getCheck
Returns the check identified by the givenidif available. -
getRepository
Returns the repository identified by the givenidif available. -
get
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
Pattern to exclude health checks from being invoked by Camel when checking healths. Multiple patterns can be separated by comma. -
isExcluded
Whether the given health check has been excluded -
setExposureLevel
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
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.
-