#1473·quartz

Add ClusterListener Support for Cluster Node Failure Detection

Author: accevolveCreated Mar 1, 2026Updated Mar 6, 2026
Labelsis:enhancement

Problem Statement

Quartz currently provides three types of listeners (JobListener, TriggerListener, SchedulerListener) to monitor various aspects of job scheduling. However, there is no mechanism to notify applications when a cluster node fails in a clustered Quartz environment.

This creates a critical monitoring gap for production deployments where operational teams need immediate awareness of cluster health issues.

Motivation / Use Cases

  1. Operational Alerting: When a Quartz node fails, operations teams need immediate notification via tools like Slack to respond to potential issues.

  2. Monitoring Integration: Cloud-native deployments need to export cluster health metrics to Prometheus, Datadog, etc. for dashboard visualization and alerting rules.

  3. Audit & Compliance: Organizations need complete logs of cluster topology changes for security auditing.

Proposed Solution

Introduce a new ClusterListener interface that follows the existing Quartz listener pattern:

java
public interface ClusterListener {
    String getName();
    void clusterNodeFailed(String failedInstanceId);
}

A support class ClusterListenerSupport will also be provided for convenience.

Integration Flow

ClusterManager detects failed node
         ↓
JobStoreSupport.clusterRecover()
         ↓
SchedulerSignaler.notifyClusterListenersNodeFailed()
         ↓
QuartzScheduler.notifyClusterListenersNodeFailed()
         ↓
All registered ClusterListeners receive notification

Key Design Decisions:

  • Notification occurs after acquiring LOCK_TRIGGER_ACCESS to ensure accuracy (only the node that actually performs recovery sends notifications)
  • Exception isolation: failure in one listener doesn't affect others
  • Fully backward compatible and optional

Usage Example

java
public class AlertingClusterListener extends ClusterListenerSupport {
    @Override
    public void clusterNodeFailed(String failedInstanceId) {
        sendAlert("Quartz cluster node failed: " + failedInstanceId);
    }
}

// Register
scheduler.getListenerManager().addClusterListener(new AlertingClusterListener());

Implementation Plan

I have implemented this feature and will submit a PR shortly. The implementation includes:

New Files:

  • org.quartz.ClusterListener - Core interface
  • org.quartz.listeners.ClusterListenerSupport - Abstract support class

Modified Files:

  • ListenerManager / ListenerManagerImpl - Add management methods
  • QuartzScheduler - Notification mechanism
  • SchedulerSignaler / SchedulerSignalerImpl - SPI integration
  • JobStoreSupport - Trigger notification on node failure detection

Test Coverage:

  • Unit tests for listener management
  • Integration tests for notification flow
  • Concurrent access tests

Benefits

✅ Solves Real Problems - Enables immediate response to cluster node failures ✅ Clean Design - Follows existing Quartz listener patterns

Backward Compatibility

Fully backward compatible. No breaking changes. This is an optional feature that users can adopt by registering listeners.