@@ -30,6 +30,10 @@ public QuartzFeature(IModule module) : base(module)
3030 /// </summary>
3131 public Action < QuartzHostedServiceOptions > ? ConfigureQuartzHostedService { get ; set ; } = options => options . WaitForJobsToComplete = true ;
3232
33+ private bool _clusteringIdentityConfigured = false ;
34+ private string ? _schedulerId ;
35+ private string ? _schedulerName ;
36+
3337 /// <summary>
3438 /// Configures the scheduler instance ID and name for clustered operation.
3539 /// </summary>
@@ -59,9 +63,13 @@ public QuartzFeature(IModule module) : base(module)
5963 /// </para>
6064 /// </remarks>
6165 public QuartzFeature ConfigureClusteringIdentity (
62- string instanceId = "AUTO" ,
66+ string instanceId = "AUTO" ,
6367 string schedulerName = "ElsaScheduler" )
6468 {
69+ _clusteringIdentityConfigured = true ;
70+ _schedulerId = instanceId ;
71+ _schedulerName = schedulerName ;
72+
6573 ConfigureQuartz += quartz =>
6674 {
6775 quartz . SchedulerId = instanceId ;
@@ -87,6 +95,23 @@ public override void Apply()
8795 if ( ConfigureQuartzOptions != null )
8896 Services . Configure ( ConfigureQuartzOptions ) ;
8997
98+ // Auto-configure clustering identity with default values if not explicitly configured
99+ if ( ! _clusteringIdentityConfigured )
100+ {
101+ ConfigureQuartz += quartz =>
102+ {
103+ if ( string . IsNullOrEmpty ( _schedulerId ) )
104+ quartz . SchedulerId = "AUTO" ;
105+ else
106+ quartz . SchedulerId = _schedulerId ;
107+
108+ if ( string . IsNullOrEmpty ( _schedulerName ) )
109+ quartz . SchedulerName = "ElsaScheduler" ;
110+ else
111+ quartz . SchedulerName = _schedulerName ;
112+ } ;
113+ }
114+
90115 Services
91116 . AddQuartz ( configure => { ConfigureQuartzInternal ( configure , ConfigureQuartz ) ; } ) ;
92117 }
0 commit comments