0

I have two instances of an app running. Is it possible for one app to check health of the other using any features of Spring framework ?

coder
  • 231
  • 3
  • 11
  • what do you mean two instances of the same app ? Can you elaborate a little more on that ? – Hary Oct 22 '18 at 07:42

2 Answers2

1

Yes. You can use Health Indicator with Actuator

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Available endpoints

/health /info /metrics /trace

it can return

{
    "status" : "UP"
}

and

{
    "status" : "DOWN",
    "myHealthCheck" : {
        "status" : "DOWN",
        "Error Code" : 1
     },
     "diskSpace" : {
         "status" : "UP",
         "free" : 209047318528,
         "threshold" : 10485760
     }
}

Read more here https://www.baeldung.com/spring-boot-actuators

Sully
  • 14,672
  • 5
  • 54
  • 79
1

To elaborate a bit on the answer by Hitham:

Let's say app A needs to report the status of App B. For that reason it seems that A depends on B for some service?

In any case, you can implement a HealthIndicator in A that attempts to call the service you need on B, using some benign, side-effect free operation.

Hans Westerbeek
  • 5,645
  • 3
  • 34
  • 35