Comments (7)
Hi @rwellman-ats,
in fact, at the moment, Quartz Manager is meant to be imported in projects which didn't import Quartz. Quartz Manager imports Quartz in a transitive way.
But I'm really interested to add this new feature you've mentioned: integration with consumer projects which already imported Quartz and their application context definitions.
Please can you elaborate which&where you've duplicated?
from quartz-manager.
Sure. I took the following approach to integrate - maybe not the best solution but I was in a hurry :)
- Set application property: quartz.enabled=false [see Note A below]
- Still requires other quartz-manager application properties (see in code snippet below)
- Duplicate a lot of config beans (see in code snippet below -also see Note B below)
[Note A] I might suggest renaming this property to 'quartz-manager.enabled' or 'quartz-manager.quartz.enabled', etc. I just think the semi-generic name you currently use might have a lot of potential for name conflict when integrating into existing codebase(s). In summary, I probably suggest renaming all your application properties to begin with 'quartz-manager'.
[Note B] You will also notice that I renamed a couple of the beans to include "QuartzManager". This is because I needed to resolve the differences between your API beans and my existing beans since there are now two beans of the same type and Spring cannot tell them apart during startup. Then I had to tell my existing config to use my existing beans by using the
@qualifier annotation like this:
@Bean
public SimpleTriggerFactoryBean trigger(@Qualifier("jobDetail") JobDetail job) {
# quartz-manager
quartz.enabled=false
quartz-manager.jobClass=org.baeldung.springquartz.basics.scheduler.SampleJobQuartzManager
job.frequency=4000
job.repeatCount=19
// =========================================================================
These are required when the quart-manager property 'quartz.enabled' = false.
// =========================================================================
@Value("${quartz-manager.jobClass}")
private String jobClassname;
@Bean(name = "triggerMonitor")
public TriggerMonitor createTriggerMonitor(@Qualifier("jobTrigger") Trigger trigger) {
TriggerMonitor triggerMonitor = new TriggerMonitorImpl();
triggerMonitor.setTrigger(trigger);
return triggerMonitor;
}
@Bean(name = "jobTrigger")
public SimpleTriggerFactoryBean sampleJobTrigger(
@Qualifier("jobDetailQuartzManager") JobDetail jobDetail,
@Value("${job.frequency}") long frequency,
@Value("${job.repeatCount}") int repeatCount) {
return createTrigger(jobDetail, frequency, repeatCount);
}
private static SimpleTriggerFactoryBean createTrigger(JobDetail jobDetail, long pollFrequencyMs, int repeatCount) {
final SimpleTriggerFactoryBean factoryBean = new SimpleTriggerFactoryBean();
factoryBean.setJobDetail(jobDetail);
factoryBean.setStartDelay(3000L);
factoryBean.setRepeatInterval(pollFrequencyMs);
factoryBean.setRepeatCount(repeatCount);
factoryBean
.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT);// in case of misfire, ignore all missed triggers and continue
return factoryBean;
}
@Bean
@SuppressWarnings("unchecked")
public JobDetailFactoryBean jobDetailQuartzManager() throws ClassNotFoundException {
Class<? extends Job> JobClass = (Class<? extends Job>) Class.forName(jobClassname);
return createJobDetail(JobClass);
}
private static JobDetailFactoryBean createJobDetail(Class<? extends Job> jobClass) {
JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
factoryBean.setJobClass(jobClass);
factoryBean.setDurability(false);
return factoryBean;
}
from quartz-manager.
Put it in the roadmap! The possibility to use quartz-manager in a project already imported Quartz.
In the meanwhile, what if you disable the dependency of Quartz in your project and let quartz-manager
to import it, enabling quartz.enabled=true
?
from quartz-manager.
I'm only trying this as an experiment to help with the what-if question. I am suggesting that this NOT be the method you expect people to take to use this project. So before you read my notes below, let me offer my two cents on how I would expect this to work when it's finished:
- First, it's just my opinion but I think MOST people would want to use your user interface project to enhance/support existing code. Therefore, you have to think about how to wire their pre-existing quartz components into your framework. (It may be difficult to automate this... you probably just have to document to tell them how to do it) This would what be offered by your current 'quartz-manager-starter-api' and 'quartz-manager-starter-ui' dependencies (and we haven't even began to talk about using this with more than one job)
- Second, for those wanting to use it as you currently have it, I would offer a different dependency i.e.
- that imports the quartz framework
- that creates required spring beans
- etc.
from quartz-manager.
So I tried this with mixed success:
- yes, it sort of worked... it even did not force me to the login page (which might help you identify/debug the other issue)
- however, when I "ran the task" via your user interface, it ran the QuartzManagerDemo job instead of the one that I specified in application.properties
- It also did not seem to pick up the job frequency nor the repeatCount from application.properties so maybe it's not using them in this scenario?
# quartz-manager
quartz.enabled=true
quartz-manager.jobClass=org.baeldung.springquartz.basics.scheduler.SampleJobQuartzManager
job.frequency=4000
job.repeatCount=19
from quartz-manager.
I am suggesting that this NOT be the method you expect people to take to use this project
Hey man, that was meant to be a temporary workaround. Nevermind, actually I put your proposal in the roadmap.
Thank you very much for sharing feedback!
from quartz-manager.
Hi @rwellman-ats ,
the new release (v4.0.4) can coexist with an existing instance of quartz, in the host project.
For further details, reach out the doc page
from quartz-manager.
Related Issues (20)
- Upgrade to angular 15 HOT 1
- Replace the deprecated angular flex
- Multiple Triggers HOT 1
- Make auto startup configurable for SchedulerFactoryBean HOT 1
- Allow `JobDataMap` for a trigger to be customized
- [QUESTION] Run `quartz-persistance` independently HOT 5
- New test based on testcontainer to verify the table initialization done by liquibase
- OpenAPI doc setup failed
- My project cannot be upgraded to a higher version, what should I do? HOT 1
- Sonar: fix major findings
- Backend Validation Messages: Customization and interoperability with host projects HOT 1
- Angular Upgrade 9 -> 14
- Trigger form: re-styling
- Misfire Instruction Mandatory
- quartz-manager-use-case repo: add README files
- Creation of a trigger of type CalendarIntervalTrigger HOT 1
- Creation of a trigger of type CronTrigger
- Creation of a trigger of type DailyTrigger
- Custom params to the job HOT 1
- CSRF Protection in case of a security model based on cookie
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quartz-manager.