public class JobLaunchingTasklet
extends java.lang.Object
implements org.springframework.batch.core.step.tasklet.Tasklet
Tasklet
implementation that uses the Spring XD MessageBus
to launch
jobs deployed within the same Spring XD cluster. This tasklet also receives the
results of the job from the same message bus.
The result of the step executing this tasklet should match that of the job that was
executed by this job. So if the tasklet executes the job foo and foo returns an
ExitStatus
of "BAR", the ExitStatus of this step
will also be "BAR".Modifier and Type | Field and Description |
---|---|
static java.lang.String |
XD_ORCHESTRATION_ID |
static java.lang.String |
XD_PARENT_JOB_EXECUTION_ID |
Modifier | Constructor and Description |
---|---|
|
JobLaunchingTasklet(MessageBus messageBus,
JobDefinitionRepository jobDefinitionRepository,
DomainRepository instanceRepository,
java.lang.String jobName,
java.lang.Long timeout) |
protected |
JobLaunchingTasklet(MessageBus messageBus,
JobDefinitionRepository jobDefinitionRepository,
DomainRepository instanceRepository,
java.lang.String jobName,
java.lang.Long timeout,
org.springframework.messaging.MessageChannel launchingChannel,
org.springframework.messaging.PollableChannel listeningChannel)
Provided for testing to be able to inject the channels for mocking.
|
Modifier and Type | Method and Description |
---|---|
org.springframework.batch.repeat.RepeatStatus |
execute(org.springframework.batch.core.StepContribution contribution,
org.springframework.batch.core.scope.context.ChunkContext chunkContext)
Uses the
MessageBus to execute a job deployed in a Spring XD cluster. |
org.springframework.batch.core.JobExecution |
getResult(org.springframework.messaging.Message<?> message) |
public static final java.lang.String XD_ORCHESTRATION_ID
public static final java.lang.String XD_PARENT_JOB_EXECUTION_ID
public JobLaunchingTasklet(MessageBus messageBus, JobDefinitionRepository jobDefinitionRepository, DomainRepository instanceRepository, java.lang.String jobName, java.lang.Long timeout)
protected JobLaunchingTasklet(MessageBus messageBus, JobDefinitionRepository jobDefinitionRepository, DomainRepository instanceRepository, java.lang.String jobName, java.lang.Long timeout, org.springframework.messaging.MessageChannel launchingChannel, org.springframework.messaging.PollableChannel listeningChannel)
messageBus
- Message bus reference to launch a job and receive it's resultsjobDefinitionRepository
- Repository used to look up the child job definitioninstanceRepository
- Repository used to look up that the child job is deployedjobName
- The name of the child job definitionlaunchingChannel
- The channel used to send the launch requestlisteningChannel
- The channel used to listen for the job resultspublic org.springframework.batch.repeat.RepeatStatus execute(org.springframework.batch.core.StepContribution contribution, org.springframework.batch.core.scope.context.ChunkContext chunkContext) throws java.lang.Exception
MessageBus
to execute a job deployed in a Spring XD cluster.execute
in interface org.springframework.batch.core.step.tasklet.Tasklet
contribution
- The contribution to the step's metrics. Not used in this casechunkContext
- Used to get a handle on the JobExecution and JobInstancejava.lang.Exception
public org.springframework.batch.core.JobExecution getResult(org.springframework.messaging.Message<?> message) throws org.springframework.messaging.MessagingException
org.springframework.messaging.MessagingException