Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SchedulerFactoryBean should not override explicit "org.quartz.scheduler.instanceName" setting with bean name [SPR-16884] #21423

Closed
spring-issuemaster opened this issue May 31, 2018 · 7 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented May 31, 2018

WangYan opened SPR-16884 and commented

The property 'instanceName' can not be set correctly while using yml file.

quartz:

    job-store-type: jdbc

    properties:

      org:

        quartz:

          scheduler:

            instanceName: someInstanceName

 

and I continue debugging in

SchedulerFactoryBean #initSchedulerFactory#Line604

if (this.schedulerName != null) {

mergedProps.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, this.schedulerName);

}

this.schedulerName is always used as default value 'quartzScheduler'.

 


Affects: 5.0.6

Issue Links:

  • #5499 Multiple schedulers

Referenced from: commits 50c9542

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 1, 2018

Stéphane Nicoll commented

This is about the Spring Boot support for Quartz and this issue tracker doesn't handle those issues, see the Spring Boot project for more details.

org.quartz.scheduler.instanceName is a key in Quartz, it is an identifier and not something you can use in a hierarchical way.

This should work

spring:
  quartz:
    properties:
      org.quartz.scheduler.instanceName: "someInstance"

Please consider asking questions on StackOverflow in the future.

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 29, 2018

Dave Minnigerode commented

Ran into the same thing. Agree with WangYan report. Is this really a boot bug? If the code checked for the key then it would have the properties work as expected. 

 

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 30, 2018

WangYan commented

Stéphane Nicoll I tried and get the same result.

"org.quartz.scheduler.instanceName" has the same effect as

org:

    quartz:

        scheduler:

            instanceName: 

 

Dave Minnigerode implementing SchedulerFactoryBeanCustomizer is another way to work out.

@Override

public void customize(SchedulerFactoryBean schedulerFactoryBean) {

// #21423

        schedulerFactoryBean.setSchedulerName("someInstance");

        schedulerFactoryBean.setOverwriteExistingJobs(true);

        schedulerFactoryBean.setStartupDelay(2);

}

 

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 30, 2018

Stéphane Nicoll commented

Juergen Hoeller A second look at this leads me to think it was intentional to "override" the schedulerName with whatever scheduler name was configured.

The problem is that this field is always initialized by BeanNameAware so as long as you create a bean for it then it will ignore the org.quartz.scheduler.instanceName property. Looking at the code it looks like it was intentional. Can you please shade some light on that?

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 30, 2018

Dave Minnigerode commented

WangYan yeah.  That's what I fell back to as well, just didn't like it :^/ so dug into why I had to and found your issue .

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Sep 19, 2018

Juergen Hoeller commented

Reopening for the purpose of letting an explicit "org.quartz.scheduler.instanceName" setting override the bean name there.

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Sep 19, 2018

Juergen Hoeller commented

We override the "org.quartz.scheduler.instanceName" property in case of a schedulerName setting now but not in case of just a bean name anymore, using the latter as a fallback only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.