<p>I have a Spring Boot 2 standalone application( not REST service) which connect to rabbit MQ and process message. The application is deployed in kubernetes. While it work great, but when Rabbit MQ remain down for little longer and in logs I see hearbeat exception 60sec and eventually connection get drop even if the rabbit mq comes up after certain time:
<a href="https://stackoverflow.com/questions/42981299/automatic-retry-connection-to-broker-by-spring-rabbitmq">Automatic retry connection to broker by spring-rabbitmq</a>
<a href="https://www.rabbitmq.com/heartbeats.html" rel="nofollow noreferrer">https://www.rabbitmq.com/heartbeats.html</a></p>
<p>While I try to manage above issue by increasing number of retry :https://stackoverflow.com/questions/45385119/how-configure-timeouts-retries-or-max-attempts-in-differents-queues-with-spring</p>
<p>but after expiry of retry still above issue comes.
How can I reboot/delete-recreate pod if I see above issue in logs from kubernetes.</p>

Rajesh
<p>The easiest way is to use <code>actuator</code>, which has a <code>/actuator/health</code> endpoint. (Note that the recent version also add <code>/actuator/health/liveness</code> and <code>/actuator/health/readiness</code>).</p>
<p>You can assign the endpoint to <code>livenessProbe</code> property of k8s. Then it will automatically restart when it is necessary. You can parameterize, when your app is down if necessary.</p>
<p>See the docs:</p>
<p><a href="http://%20https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">Kubernetes liveness probe</a></p>
<p><a href="https://spring.io/blog/2020/03/25/liveness-and-readiness-probes-with-spring-boot" rel="nofollow noreferrer">Spring actuator health</a></p>
