<p>I would like to know/get opinions on how to setup liveness probe for a RabbitMQ queue consumer. I am not sure how to verify if consumer is still processing messages from the queue. I have already tried searching for some clues over the internet but could not find any. So just asking a question here to see if anyone has got any idea. </p>

<p>The code block which I want to make sure working fine is</p>

<pre><code>                var consumer = new EventingBasicConsumer(channel);
                consumer.Received += (model, ea) =&gt;
                {
                    var body = ea.Body;
                    var message = Encoding.UTF8.GetString(body);
                    Console.WriteLine($"Message Received: {message}");
                };
</code></pre>

<p>Thank you.</p>

Alpesh
<p>First thing, you will need to expose an HTTP endpoint in your application code that checks whether the consumer is alive or not.</p>

<p>There are many ways to test the liveness of the consumer, for example, you can check the timestamp of the last message that was consumed. If it's too old, you could declare the consumer as dead by returning an HTTP 500 error, otherwise, return HTTP 200. It depends on your business logic, you might want to use what I proposed, or any other method that fits your needs.</p>

<p>Once you have an HTTP endpoint, you can define a liveness probe in your Kubernetes manifest.</p>

<pre><code>livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
        httpHeaders:
        - name: X-Custom-Header
          value: Awesome
      initialDelaySeconds: 3
      periodSeconds: 3
</code></pre>

<p>(Taken from <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/</a>)</p>
