0

I'm using smallrye healthcheck to check the liveness and readiness of the rabbitmq container.

http://localhost:8080/q/health/live

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-smallrye-health</artifactId>
</dependency>

The health check does not identify that the container has stopped or when it only identifies after 2 hours. I tried to do a custom health check but it doesn't pop an error when using the emitter for the specified channel.

package com.globalcards.adapter.driver.config;

import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Liveness;
import org.eclipse.microprofile.reactive.messaging.Channel;
import org.eclipse.microprofile.reactive.messaging.Emitter;
import org.eclipse.microprofile.reactive.messaging.Message;
import org.eclipse.microprofile.reactive.messaging.Outgoing;

import javax.enterprise.context.ApplicationScoped;


@ApplicationScoped
@Liveness
public class CustomHealthLivenessRabbitMq implements HealthCheck {
     @Channel("sends")
     Emitter<String> invoyceTypeRequestEmitter;
    
     @Override
      public HealthCheckResponse call() {
         try {
             invoyceTypeRequestEmitter.send("healthcheck");
             return HealthCheckResponse.builder().up().name("RabbitMQ container is ready ").build();
         } catch (Exception exception) {
               return HealthCheckResponse.builder().down().name("RabbitMQ container is not readyds").build();
         }
     }
    
     @Outgoing("sends")
     public String outgoing() {
         return "healthcheck";
     }
}

Can anyone help me or have you been through this?

HoRn
  • 1,458
  • 5
  • 20
  • 25
  • if invoyceTypeRequestEmitter is not throwing any exception it means it is working, what error do you get ? or can you explain your problem more clearly ? – ozkanpakdil Apr 16 '23 at 17:37

0 Answers0