I know it's kind of late to answer your question but here is my method for letting know the consumers that the producer is alive : you can add a ping message for example inside a Task which will publish to RabbitMQ each X seconds.
This solution works with ACKS back from RMQ and it works when you have a big number of messages coming in. This does not affect your performance by using ACKS
For example, taking the code in C# :
...
m_mainTimer = new System.Timers.Timer();
m_mainTimer.Interval = 10000; // every 10 secs
m_mainTimer.Elapsed += m_mainTimer_Elapsed;
m_mainTimer.AutoReset = false; // makes it fire only once
m_mainTimer.Start(); // Start
...
void m_mainTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e){
try {
// send to RMQ
sendMessageToRabbitMQ("PING", "error");
m_timerTaskSuccess = true;
} catch (Exception ex) {
m_timerTaskSuccess = false;
} finally {
if (m_timerTaskSuccess) {
m_mainTimer.Start();
}
}
}
The actual message in RMQ:
{
"Message": "PING",
"Timestamp": 1620303014184
}
If you don't get this message in less than 11 seconds you know there is a problem.
I hope it helps the others as well.