WildFly: Example for MicroProfile Health (Simple)

Parent POM for JBoss projects. Provides default project build configuration.

License

License

Categories

Categories

WildFly Container Application Servers
GroupId

GroupId

org.wildfly
ArtifactId

ArtifactId

microprofile-health-simple-example
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

war
Description

Description

WildFly: Example for MicroProfile Health (Simple)
Parent POM for JBoss projects. Provides default project build configuration.
Project Organization

Project Organization

JBoss by Red Hat

Download microprofile-health-simple-example

How to add to project

<!-- https://jarcasting.com/artifacts/org.wildfly/microprofile-health-simple-example/ -->
<dependency>
    <groupId>org.wildfly</groupId>
    <artifactId>microprofile-health-simple-example</artifactId>
    <version>1.0.0</version>
    <type>war</type>
</dependency>
// https://jarcasting.com/artifacts/org.wildfly/microprofile-health-simple-example/
implementation 'org.wildfly:microprofile-health-simple-example:1.0.0'
// https://jarcasting.com/artifacts/org.wildfly/microprofile-health-simple-example/
implementation ("org.wildfly:microprofile-health-simple-example:1.0.0")
'org.wildfly:microprofile-health-simple-example:war:1.0.0'
<dependency org="org.wildfly" name="microprofile-health-simple-example" rev="1.0.0">
  <artifact name="microprofile-health-simple-example" type="war" />
</dependency>
@Grapes(
@Grab(group='org.wildfly', module='microprofile-health-simple-example', version='1.0.0')
)
libraryDependencies += "org.wildfly" % "microprofile-health-simple-example" % "1.0.0"
[org.wildfly/microprofile-health-simple-example "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.eclipse.microprofile.health : microprofile-health-api jar 1.0

provided (1)

Group / Artifact Type Version
javax : javaee-api jar 7.0

Project Modules

There are no modules declared in this project.

wildfly-microprofile-health

WildFly Extension for Eclipse MicroProfile Health.

Instructions

mvn clean install

Project structure

  • extension - WildFly Extension that provides the microprofile-health subsystem.
  • feature-pack - Feature pack that bundles the extension with the JBoss Modules required to run it in WildFly.
  • dist - A distribution of WildFly with the microprofile-health extension installed (in its standalone-microprofile.xml configuration)
  • examples - Examples of an applications that provides Health Check Procedures

Usage

Start WildFly with the microprofile-health extension installed:

$> export JBOSS_HOME=dist/target/microprofile-health-x-x-x
$> cd $JBOSS_HOME
$> ./bin/standalone.sh -c standalone-microprofile.xml
...
13:45:33,808 INFO  [org.wildfly.extension.microprofile.health] (ServerService Thread Pool -- 47) EMPHEALTH0001: Activating Eclipse MicroProfile Health Subsystem
...
13:45:35,010 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Core 3.0.0.Beta11 "Kenny" started in 3507ms - Started 246 of 292 services (88 services are lazy, passive or on-demand)

You can perform a health check using WildFly CLI Console by invoking the /subsystem=microprofile-health:check operation


$> $JBOSS_HOME/bin/jboss-cli.sh -c
[standalone@localhost:9990 /] /subsystem=microprofile-health:check
{
    "outcome" => "success",
    "result" => {
        "checks" => [{
            "id" => "heap-memory",
            "result" => "UP",
            "data" => {
                "max" => "477626368",
                "used" => "156216336"
            }
        }],
        "outcome" => "UP"
    }
}

Alternatively, you can use HTTP to perform a health check using the URL http://localhost:8080/health/:

{
   "checks":[
      {
         "id":"heap-memory",
         "result":"UP",
         "data":{
            "max":"477626368",
            "used":"160137128"
         }
      }
   ],
   "outcome":"UP"
}

If you now deploy the demo.war (from the examples/simple directory), its health check procedures will also be taken into account to determine the overal healthiness of the server:

$> $JBOSS_HOME/bin/jboss-cli.sh -c
[standalone@localhost:9990 /] deploy $WORKDIR/wildfly-microprofile-health/examples/simple/target/demo.war

You go again to http://localhost:8080/health/, you will see that the outcome will be down when the random health check procedure defined by the Web application is (randomly) down:

{
   "checks":[
      {
         "id":"heap-memory",
         "result":"UP",
         "data":{
            "max":"477626368",
            "used":"174963568"
         }
      },
      {
         "id":"random",
         "result":"DOWN",
         "data":{
            "foo":"bar"
         }
      }
   ],
   "outcome":"DOWN"
}

Note that when the overall outcome is down, the HTTP returns a 503 Service Unavailable status code along with the JSON payload. If the overall outome is down, the returned status code in in the 20x range.

Links

Versions

Version
1.0.0