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

Add section on clustered Quartz scheduler [SPR-13649] #18225

Open
spring-issuemaster opened this issue Nov 6, 2015 · 0 comments
Open

Add section on clustered Quartz scheduler [SPR-13649] #18225

spring-issuemaster opened this issue Nov 6, 2015 · 0 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Nov 6, 2015

Andrei Ivanov opened SPR-13649 and commented

Trying to create a clustered Quartz configuration is a bit difficult since the reference documentation doesn't have any info about it and Google returns some pretty old blog posts with old versions of Spring.

What I would like to see improved:

  • section on creating a clustered scheduler.
    Something like
<bean id="taskScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
	<property name="dataSource" ref="dataSource" />
	<property name="transactionManager" ref="transactionManager" />
	<property name="taskExecutor" ref="taskExecutor" />
	<property name="overwriteExistingJobs" value="true" />
	<property name="quartzProperties">
		<props>
			<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
			<prop key="org.quartz.jobStore.tablePrefix">qrtz_</prop>
			<prop key="org.quartz.jobStore.isClustered">true</prop>
			<prop key="org.quartz.jobStore.useProperties">true</prop>
		</props>
	</property>
</bean>
  • A note regarding MethodInvokingJobDetailFactoryBean that it can't be used for clustered Quartz (or even better, improve it to work)
  • A sample of a jobDetail with DI, I assume with SpringBeanJobFactory
    The way I've done this is by using @Configurable, as would make DI work on deserialization too (I've used the same approach on JSF beans)
@Configurable
public class UsersSyncJob extends QuartzJobBean implements Serializable {
	@Autowired
	private transient UserFacade userFacade;

	@Override
	protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
		userFacade.syncUsers();
	}
}
  • Sample usage of SchedulerAccessorBean for when you want to register jobs/triggers from separate modules (I've discovered this nice utility by looking at the source code):
<bean class="org.springframework.scheduling.quartz.SchedulerAccessorBean">
	<property name="scheduler" ref="taskScheduler" />
	<property name="triggers">
		<list>
			<ref bean="usersSyncJobTrigger" />
		</list>
	</property>
</bean>

1 votes, 2 watchers

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
1 participant
You can’t perform that action at this time.