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 HealthCheckRegistry
get
(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 givenid
if 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 givenid
if available.boolean
Whether Health Check is enabled globallyboolean
isExcluded
(HealthCheck healthCheck) Whether the given health check has been excludedvoid
Loads custom health checks by scanning classpath.boolean
Registers aHealthCheck
orHealthCheckRepository
.resolveById
(String id) ResolvesHealthCheck
orHealthCheckRepository
by id.void
setEnabled
(boolean enabled) Whether Health Check is enabled globallyvoid
setExcludePattern
(String excludePattern) Pattern to exclude health checks from being invoked by Camel when checking healths.void
setExposureLevel
(String exposureLevel) Sets the level of details to exposure as result of invoking health checks.void
setInitialState
(HealthCheck.State initialState) The initial state of health-checks (readiness).stream()
Returns a sequentialStream
with the knownHealthCheck
as its source.boolean
unregister
(Object obj) Unregisters aHealthCheck
orHealthCheckRepository
.Methods inherited from interface org.apache.camel.CamelContextAware
setCamelContext
Methods inherited from interface org.apache.camel.spi.HasCamelContext
getCamelContext
Methods 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
ResolvesHealthCheck
orHealthCheckRepository
by id. Will first lookup in thisHealthCheckRegistry
and 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
HealthCheck
orHealthCheckRepository
, or null if none found.
-
register
Registers aHealthCheck
orHealthCheckRepository
. -
unregister
Unregisters aHealthCheck
orHealthCheckRepository
. -
getCheckIDs
A collection of health check IDs. -
getCheck
Returns the check identified by the givenid
if available. -
getRepository
Returns the repository identified by the givenid
if 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 sequentialStream
with the knownHealthCheck
as 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.
-