Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Can I create a Spring context within a Quartz job or it is a terrible idea?

I am new to Quartz and I am going to write jobs that require a lot of services/dependencies.

Would it make sense to create a Spring context in the job execute method (so for any new job there will a new Spring context) or is it better to create a unique Spark context before the jobs get created and inject services for any new job?

Thank you.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

That depends on your requirements and preferences.

If your job only starts at a determined time of the day, something like everyday at 3:00 am. Then it's not important that your spring context takes to starts a couple of minutes. In this case or any other case where it's not important the time until the context is up and running, I suggest you to start the context every time a job is started. It has no sense to keep a context up and running along the hole day if you only will use it a little part of it.

However, you can have a lot of jobs. And probably it does not matter the time they take to be up and running. But if they are many, it will use a lot of memory starting a new context for every job. So, in this case I would recommend you to init a unique spring context. So you can optimize the memory of your server.

Other case, would be that the start up time matters. In this case, it's better to have the spring context up and running, so you can use it, every time you need almost immediately.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!