Class UrlHealthCheck

  • All Implemented Interfaces:
    org.eclipse.microprofile.health.HealthCheck

    public class UrlHealthCheck
    extends Object
    implements org.eclipse.microprofile.health.HealthCheck
    Health check implementation to check if host is reachable using a Http URL connection.
     
     @Produces
     @ApplicationScoped
     @Liveness
     HealthCheck check1() {
         return new UrlHealthCheck("www.google.com");
     }
     
     
    See Also:
    Socket
    • Constructor Detail

      • UrlHealthCheck

        public UrlHealthCheck​(String url)
    • Method Detail

      • call

        public org.eclipse.microprofile.health.HealthCheckResponse call()
        Specified by:
        call in interface org.eclipse.microprofile.health.HealthCheck
      • name

        public UrlHealthCheck name​(String name)
        Sets the name of the health check.
        Parameters:
        name - of health check.
        Returns:
        UrlHealthCheck instance.
      • timeout

        public UrlHealthCheck timeout​(int timeout)
        Sets timeout in millis.
        Parameters:
        timeout - in millis.
        Returns:
        UrlHealthCheck instance.
      • statusCode

        public UrlHealthCheck statusCode​(int statusCode)
        Sets the expected status code to be returned as valid.
        Parameters:
        statusCode - expected.
        Returns:
        UrlHealthCheck instance.
      • requestMethod

        public UrlHealthCheck requestMethod​(String requestMethod)
        Sets the request method to be used (ie GET, POST, PUT, ...)
        Parameters:
        requestMethod - to use.
        Returns:
        UrlHealthCheck instance.