-
1. Re: Run a job starting at a specific step
richardmoore Dec 2, 2016 4:05 PM (in response to richardmoore)I just realized that we might have already solved this. Is this what we would do -
1. start job
2. job listener beforeJob use JobContextImpl.getJobExecution().setRestartPosition(stepIdName)
For future reference, here is the code we are using in #2 above that is working -
import java.util.logging.Logger;
import javax.batch.api.listener.AbstractJobListener;
import javax.batch.runtime.context.JobContext;
import javax.enterprise.context.Dependent;
import javax.inject.Inject;
import javax.inject.Named;
import org.jberet.runtime.context.JobContextImpl;
import com.awginc.batch.JavaBatchExecutor;
@Dependent
@Named()
public class JobRestartListener extends AbstractJobListener {
@Inject
private JobContext jobContext;
@Override
public void beforeJob() throws Exception {
JobContextImpl jci = (JobContextImpl) jobContext;
String restartPosition = System.getProperty(JavaBatchExecutor.restartStep);
if (restartPosition != null) {
log.info("Restarting in " + restartPosition);
jci.getJobExecution().setRestartPosition(restartPosition);
} else {
String startPosition = System.getProperty(JavaBatchExecutor.startStep);
if (startPosition != null) {
log.info("Starting in " + restartPosition);
jci.getJobExecution().setRestartPosition(startPosition);
}
}
}
private final Logger log = Logger.getLogger(this.getClass().getSimpleName());
}
-
2. Re: Run a job starting at a specific step
cfang Dec 2, 2016 4:35 PM (in response to richardmoore)JBERET-256 Support custom restart step/position
We recently added support for specifying custom restart position as job parameter, without using JBeret internal API.
params.setProperty("jberet.restart.position", "step1");
jobExecutionId = jobOperator.restart(jobExecutionId, params);
For more details, see the tests (testRestartPosition1, testRestartPosition2, testRestartPosition3) in the above issue.
-
3. Re: Run a job starting at a specific step
cfang Dec 2, 2016 4:37 PM (in response to cfang)previous discussion: