I am currently facing an issue with my Tasks invocation in Spring Cloud Data Flow.
I have an Spring Batch (containing single-tasklet-step job) application registered on SCDF and a task definition based on this app. During my first launch of this task, I used a couple job parameters/arguments. Due a reason that I do now know, all my subsequent launches are getting their parameters overriden by the first set I used.
I am using SCDF 1.4.0 + MSSQL Database, but the very same behavior happens using SCDF 1.3.2 + H2 or MSSQL as well.
BatchConfig.java
@Configuration
public class BatchConfig {
@Autowired
TaskletStep taskletStep;
@Autowired
public JobBuilderFactory jobBuilderFactory;
@Autowired
public StepBuilderFactory stepBuilderFactory;
@Bean
public Step step1() {
return stepBuilderFactory.get("step1")
.tasklet(taskletStep)
.build();
}
@Bean
public Job job() throws Exception {
return jobBuilderFactory.get("job")
.incrementer(new RunIdIncrementer())
.start(step1())
.build();
}
}
TaskletStep.java:
@Configuration
@StepScope
public class TaskletStep implements Tasklet{
@Value("#{jobParameters['filePath']}")
private String filePath;
@Value("#{jobParameters['informante']}")
private String informante;
@Autowired
RemessaParser remessaParserService;
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
GICLogger.info("Recebido job com path: " + filePath + " para o informante "+ informante);
try{
Path remessa = Paths.get(filePath);
if(Files.exists(remessa)){
String idRemessa = remessaParserService.remessaReader(remessa, informante);
GICLogger.info("### TaskletStep:" + idRemessa + " é o ID da Remessa!");
return RepeatStatus.FINISHED;
}else{
GICLogger.error("Não foi possível encontrar a remessa em "+filePath);
}
}catch(Exception e){
e.printStackTrace();
}
return RepeatStatus.FINISHED;
}
}
My launch command:
dataflow> task launch negTask --arguments "filePath=/tmp/jars/remessa.txt informante=CaixaB --spring.cloud.task.closecontext_enable=false"
Application log:
2018-04-04 13:33:28 [main] INFO c.b.g.n.BatchNegativacaoApp - Started BatchNegativacaoApp in 13.938 seconds (JVM running for 14.599)
2018-04-04 13:33:28 [main] INFO o.s.b.a.b.JobLauncherCommandLineRunner - Running default command line with: [filePath=/tmp/jars/remessa.txt, informante=Caixa, --spring.cloud.task.closecontext_enable=false, --spring.cloud.task.executionid=17]
2018-04-04 13:33:28 [main] INFO o.s.b.c.l.support.SimpleJobLauncher - Job: [SimpleJob: [name=job]] launched with the following parameters: [{filePath=/home/enrico/PROJETOS/GIC/java/remessa.txt, -spring.cloud.task.executionid=8, informante=Caixa, -spring.cloud.task.closecontext_enable=false, run.id=12, time=1522842134819}]
Do you guys have any idea of why does it happen?
Thanks for your attention and any input!
Best regards, Enrico
@Configuration
on yourTaskletStep
. Just use@Component
. What was the result of the previous launch (COMPLETE
orFAILED
)? – Michael Minella