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

How to run a job only once at application start time? #621

Closed
Vwings opened this issue Jan 22, 2019 · 2 comments
Closed

How to run a job only once at application start time? #621

Vwings opened this issue Jan 22, 2019 · 2 comments

Comments

@Vwings
Copy link

Vwings commented Jan 22, 2019

Please answer these questions before submitting your issue. Thanks!
开源不易,我们希望将精力放在完成新功能和解决有价值的问题上,为了让大家的配合更具有效率,请填写以下列出的全部问题

Which version of Elastic-Job do you using?(您使用的Elastic-Job版本为?)

2.0.5

Expected behavior (您预期的结果是)

Config a job that run only once at start time.

Actual behavior (实际运行的结果是)

Cannot find the configuration

Steps to reproduce the behavior (可重现问题的操作步骤)

Please provide the reproduce example codes (such as github link),otherwise we will label the issue as Invalid and close it.(为了节省复现问题的时间,请务必提供可重现的代码,否则我们会将issue直接标记为invalid并关闭)

Maybe a configuration like 'init-job=true' to mark as a startup job

<job:simple
        id="myJob"
	class="MySimpleJob"
	registry-center-ref="regCenter"
	sharding-total-count="12"
        init-job="true">
</job:simple>

Code should based on https://github.com/elasticjob/elastic-job-example
(代码请基于 https://github.com/elasticjob/elastic-job-example)

@Leonidasz
Copy link
Contributor

elastic-job采用的trigger是CronTrigger,主要针对的是定时调度的场景。
建议在你的作业执行的业务逻辑内加上控制逻辑,作业执行一次后设置状态位,后续的作业调度时判断状态位,如果状态位被修改,不进行实际的业务处理。

@compilerduck
Copy link

与#624重复了,后续请关注#624的最新更新,关闭此issue。

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

No branches or pull requests

3 participants