添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am sorry if this question is too naive, I am expecting the jobs to be scheduled so that it executes one by one, and not parallely.It is executed only once.

From docs, @DisallowConcurrentExecution is

  • An annotation that marks a {@link Job} class as one that must not have multiple instances executed concurrently (where instance is based-upon a {@link JobDetail} definition - or in other words based upon a {@link JobKey}).
  • But when I schedule a job with same JobKey, I am getting Failed to schedule a job org.quartz.ObjectAlreadyExistsException

    If I generate a different JobKey, it is not heeding to @DisallowConcurrentExecution and the job is getting executed in parallel(as mentioned in docs).

    Please suggest how can I achieve this, any pointers would really help!

    PS: I do not know the jobs that would be scheduled. So, I need some method to dynamically link up the jobs,if the job is already running.

    Different JobKey = different job.

    Quartz won't let you use the same JobKey more than once because that'd be two jobs with the same key. Like having two users with the same ID.

    What you need to do is schedule different JobTrigger s for the same JobKey .

    @DisallowConcurrentExecution avoids overlapping executions of the same job. If you use a different JobKey , it's not the same job anymore, so the annotation doesn't have any effect. But for a given JobKey with several JobTrigger s, @DisallowConcurrentExecution will keep the triggers from launching a new execution of the job, if the previous one hasn't finished yet.

    I suggest having a look at Quartz's documentation to get a deeper understanding of the above concepts.

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question . Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers .