Hi Everyone,
Currently I have a problem with my code, I am trying to pass object between steps. is that possible to do that ? I try to use JobExecutionContext but have exception when running my job.
Thank you
Hi Everyone,
Currently I have a problem with my code, I am trying to pass object between steps. is that possible to do that ? I try to use JobExecutionContext but have exception when running my job.
Thank you
My workaround for this is by retrieving reference to JobExecution, then put the object on its ExecutionContext.
But it seem long way just to pass object between step, is there any other shorter path perhaps?
regards
Hello DHGarrette,
I followed the instruction in the link. I'm using Spring Batch 2.0.0, though this version supports Annotations the @AfterStep and @BeforeStep annotations did not work (i.e. not invoked by Spring Batch container). To overcome this I did following.
Step 1: Implementedinterface both the Tasklets (i.e. step1 tasklet and step2 tasklet)Code:StepExecutionListener
Step 2: I set the value to be passed to next step Inmethod as followsCode:afterStep(StepExecution)
Step 3: To read the value from step2 tasklet follow the below simple code inCode:stepExecution.getJobExecution().getExecutionContext().put("key", anyObject);Code:beforeStep(StepExecution)Though the above steps help me to pass objects between Steps, could you please tell me what might cause the Annotations @BeforeStep and @AfterStep to not work?Code:stepExecution.getJobExecution().getExecutionContext().get("key");
Did you register the annotated objects using the <listeners/> tag in the xml?
DHGarrette,
No, I did not add the annotated objects in listeners tag. Once I added the annotated object in listeners tag it started working. Thanks for the tip!
Hi,
could you provide the full example code please?
Don't.
Thread is 2 years old.