Spring boot healthcheck

Generate REST API "/healthcheck" in your spring boot web project.

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

com.studio4365
ArtifactId

ArtifactId

spring-boot-healthcheck
Last Version

Last Version

1.00
Release Date

Release Date

Type

Type

jar
Description

Description

Spring boot healthcheck
Generate REST API "/healthcheck" in your spring boot web project.
Project URL

Project URL

https://github.com/james628/spring-boot-healthcheck
Project Organization

Project Organization

Pivotal Software, Inc.
Source Code Management

Source Code Management

https://github.com/james628/spring-boot-healthcheck.git

Download spring-boot-healthcheck

How to add to project

<!-- https://jarcasting.com/artifacts/com.studio4365/spring-boot-healthcheck/ -->
<dependency>
    <groupId>com.studio4365</groupId>
    <artifactId>spring-boot-healthcheck</artifactId>
    <version>1.00</version>
</dependency>
// https://jarcasting.com/artifacts/com.studio4365/spring-boot-healthcheck/
implementation 'com.studio4365:spring-boot-healthcheck:1.00'
// https://jarcasting.com/artifacts/com.studio4365/spring-boot-healthcheck/
implementation ("com.studio4365:spring-boot-healthcheck:1.00")
'com.studio4365:spring-boot-healthcheck:jar:1.00'
<dependency org="com.studio4365" name="spring-boot-healthcheck" rev="1.00">
  <artifact name="spring-boot-healthcheck" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.studio4365', module='spring-boot-healthcheck', version='1.00')
)
libraryDependencies += "com.studio4365" % "spring-boot-healthcheck" % "1.00"
[com.studio4365/spring-boot-healthcheck "1.00"]

Dependencies

compile (2)

Group / Artifact Type Version
commons-collections : commons-collections jar 3.2
org.springframework.boot : spring-boot-starter-web jar 1.2.6.RELEASE

test (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 1.2.6.RELEASE

Project Modules

There are no modules declared in this project.

spring-boot-healthcheck

Generate REST API "/healthcheck" in your spring boot web project.

"/healthcheck" provide many things.

  1. Server status
  2. Database status
  3. Redis status
  4. Current application version

EX)

REQUEST (GET) - http://yourdomain.com/healthcheck

RESPONSE - Content-Type: application/json
	{
		"return_message":"success",
		"context":{
			"db_response_time":2,
			"redis_response_time":1
		},
		"return_code":0,
		"version":"1.10",
		"timestamp":1472708562590
	}

Getting started

  1. import library into your spring boot project

    • maven
    <dependency>
    	<groupId>com.studio4365</groupId>
    	<artifactId>spring-boot-healthcheck</artifactId>
    	<version>1.00</version>
    </dependency>
    
    • gradle
    compile('com.studio4365:spring-boot-healthcheck:1.00')
    
    • ivy
    <dependency org="com.studio4365" name="spring-boot-healthcheck" rev="1.00"/>
    
  2. Create your healthCheckClass java file with implements HealthCheckInterface

    ex) HealthCheckClassSample.java

    import com.studio4365.spring.healthcheck.HealthCheckInterface;
    
    public class HealthCheckClass implements HealthCheckInterface {
    	@Override
    	...
    }
    
  3. Add healthCheckClassFullName into your application.properties or other Environment properties healthCheckClassFullName=com.studio4365.spring.healthcheck.HealthCheckClass

  4. Add basePackage "com.studio4365.spring.healthcheck" in your Component-scan setting

    • Annotation driven
    @ComponentScan(basePackages={"com.yourdomain", "com.studio4365.spring.healthcheck"})
    
    • XML driven
    <context:component-scan base-package="com.yourdomain, com.studio4365.spring.healthcheck" />
    

Practice

  1. AWS Elastic load balancer(ELB) Health Check

    Ping Target : HTTP:8080/healthcheck

    ELB default ping protocol TCP just check open port. It doesn't know about status of your application. If you use HTTP with "/healthcheck", you can know server status, database status, redis status and version after deploy.

Versions

Version
1.00