Replies: 1 comment 1 reply
-
Hi @flowt-au, This is again not specific to Health extension, but I'll try to help. When you use the reactive REST client, all status codes other than 200 are, by default, converted to exceptions. This is why you don't see the DOWN Health JSON in your logs/retries of your Uni. The target application, however, always responds with the JSON, as this is spec required. Here I tried to reproduce your application - https://github.com/xstefank/call-health. Here you can see a custom exception mapper that forwards the response - https://github.com/xstefank/call-health/blob/main/src/main/java/org/acme/OrgHealthProxy.java#L30-L38. According to https://quarkus.io/guides/rest-client-reactive#using-clientexceptionmapper if you would like to learn more. And then you can pick the response (because you know it's the WebApplicationException) in the failure handler - https://github.com/xstefank/call-health/blob/main/src/main/java/org/acme/OrgContainerHealth.java#L95-L98. Hopefully, this helps. Feel free to ask if you have more questions. Martin |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is more of a "how to" than a question. Also looking for suggestions for improvement.
I have a Quarkus app with health checking enabled running in a container on port 9000. I can make a health request to that app on
q/health
from another Quarkus app (call it app2). If the status is UP, it returns the health json and http status 200. If the status is DOWN it returns status 503 (Service not available) and no data. This is the usual thing.However, my use-case is I am using
docker-java
to create the container of the target Quarkus app and I need to poll for it being ready so I can start sending requests to it. I want to keep checking the health for (say) 6 seconds and I wanted to receive the health data even if the health status was DOWN (so I can see what didn't work and get some extra data back via "withData").Here is what I am doing in case others need to so something like this. Any suggestions for improvement are welcome.
Kudos to @xstefank for help via: this SO answer
First, in the target Quarkus app I created a "readiness" check as per the Quarkus guide. Nothing special here. It can be configured to return UP or DOWN for testing.
Next, in the target Quarkus app I created a standard REST endpoint called
/myhealth
to use instead of theq/health
endpoint. My custom health endpoint returns the health data and status 200.From a browser,
http://localhost:9000/myhealth
andhttp://localhost:9000/q/health
both return the health data when the status is UP, but/myhealth
returns a status 200 and the data even when the status is DOWN.In the Quarkus app requesting the health data I created a proxy:
The container is created and run via
docker-java
. ie in summary:Then I call the proxy via this function:
So, when it runs, I get a couple of
getHealthDataFromOrgContainer REST request for container xxxx failed because: io.vertx.core.http.HttpClosedException: Connection was closed
because the container isn't accepting requests yet.Then, when it is UP, I get the health JSON and return it.
If it is not up within the timeout period, I get the health json and return that by recovering from the failure. My caller can then decide what to do about the failure after inspecting the overall status and the sub-status data.
Anyway, maybe helpful for someone.
Murray
Beta Was this translation helpful? Give feedback.
All reactions