Configure Quartz.NET to Trigger Sending Batches of Messages Without Heartbeat Errors

I am using NSB 7.7.3 and .NET 6.

My application uses Quartz.NET to trigger a process every 15 minutes that results in a batch of messages being sent by NServiceBus (a foreach loop iterates through the message batch to send each one). This works as expected, however the sending endpoint continuously triggers HeartbeatStopped and HeartbeatRestored messages via the NSB Custom Events Handler.

I read through the NSB Quartz.NET Usage document, which injects and extracts the IEndpointInstance from the Quartz scheduler context and allows one to trigger the sending of a single message, however I could not see a way to adapt it to my batch-send situation.

Is there a way to send batches of NServiceBus messages at a regular interval without triggering the Heartbeat messages (and still allowing for HeartbeatStopped and HeartbeatRestored to trigger when the actual endpoint goes down, as opposed to during the interval while waiting for Quartz)? Thank you.

I see a few options here:

  • Configure the Quartz endpoint as a send-only endpoint which would probably stop it from sending heartbeats altogether.
  • Disable heartbeats, or rather, don’t include the NServiceBus.Heartbeat that sends them.
  • It sounds like the endpoint instance is being created and then destroyed for every iteration of the Quartz trigger. It should probably be a long-lived (even static) reference, and then, I would argue it should still be configured as send-only, but then you could configure heartbeats and it would deliver them continuously between timer ticks.

Thanks David. Despite having my Quartz jobs and triggers as static, the HeartbeatStopped and HeartbeatRestored messages were still issued. Additionally, this happens several times during each 15 minute Quartz interval, so the endpoint instance seems to be created and destroyed multiple times between Quartz triggers.

endpointConfiguration.SendOnly does indeed stop the endpoint from sending heartbeats and it is in my code for the moment. However, the hope at my company was to be able to view the heartbeat for the current SendOnly endpoint on ServicePulse and monitor when messages are sent. Much appreciate the assistance.

For anyone who stumbles upon this in the future, I was unable to resolve the Heartbeats issues when sending batch messages at intervals. I ended up removing Heartbeat monitoring (the Heartbeat NuGet package and associated code) from my application as David suggested.