Durability Agent


If you add one of the database-backed message persistence providers to your Jasper application, Jasper will run a DurabilityAgent in the background of your application (utilizing .Net Core's IHostedService functionality). If you keep the logging level all the way down to Debugging, you'll see a great deal of tracing from this process. The DurabilityAgent is polling your application database looking for:

  1. Persisted messages that were scheduled later for execution or sending that are ready to out
  2. Moving message ownership over from nodes that appear to be offline
  3. Recovering persisted, outgoing messages that are not actively owned by any running node and sending them on their way
  4. Recovering persisted, incoming messages that are not actively owned by any running node and executing them in the local node

At this point, Jasper relies very heavily on advisory locks in Postgresql or application locks in Sql Server to coordinate activities across running nodes of the same system.

There are a few configuration items of the DurabilityAgent you might want to tweak in your system:


public class DurabilityAgentCustomization : JasperOptions
{
    public DurabilityAgentCustomization()
    {
        // Control the maximum batch size of recovered
        // messages that the current node will try
        // to pull into itself
        Advanced.RecoveryBatchSize = 500;


        // How soon should the first node reassignment
        // execution to try to look for dormant nodes
        // run?
        Advanced.FirstNodeReassignmentExecution = 1.Seconds();

        // Fine tune how the polling for ready to execute
        // or send scheduled messages
        Advanced.ScheduledJobFirstExecution = 0.Seconds();
        Advanced.ScheduledJobPollingTime = 60.Seconds();
    }
}