2) use own java beans to pass data.
- This is data holder to be passed across steps
public class PublicCompanyHolder {
private List<PublicCompanyInfo> publicCompanyList;
public List<PublicCompanyInfo> getPublicCompanyList() {
return publicCompanyList;
}
public void setPublicCompanyList(List<PublicCompanyInfo> publicCompanyList) {
this.publicCompanyList = publicCompanyList;
}
}
- set data to holder in step 1
public class PubTasklet implements Tasklet {
@Autowired
private PublicCompanyHolder publicCompanyHolder;
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
List<PublicCompanyInfo> infoContainer = new ArrayList<PublicCompanyInfo>();
for (int i=0; i < 10; i++) {
PublicCompanyInfo info = new PublicCompanyInfo();
info.setPublicCompanyId("ID-" + i);
info.setPublicCompanyName("Name*" + i);
infoContainer.add(info);
}
publicCompanyHolder.setPublicCompanyList(infoContainer);
return RepeatStatus.FINISHED;
}
}
- get data from holder in step 2
@Component("pubTasklet2")
public class PubTasklet2 implements Tasklet {
@Autowired
private PublicCompanyHolder publicCompanyHolder;
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
System.out.println("received holder:" + publicCompanyHolder.getPublicCompanyList());
return RepeatStatus.FINISHED;
}
}
- define the job
<job id="pubJob" restartable="true">
<step id="step1" next="step2">
<tasklet ref="pubTasklet" />
</step>
<step id="step2" next="step1"> // if you do not want to loop, remove next
<tasklet ref="pubTasklet2" />
</step>
<listeners>
<listener ref="pubListener" />
</listeners>
</job>
I have a similar requirement. But in my case its in multi threaded environment. Do you think this design is threadsafe?
ReplyDeleteIs it possible to share data between jobs. I want to read data from file and will store in hash map and next day whn same job will run, it will first check cache, it data is stored, i want to use that data only, dont want to read same file again, Is it possible?
ReplyDeleteI don't think your code is threadsafe: PublicCompanyHolder has singleton scope which means it is shared by multiple threads. Using @Scope("job") on PublicCompanyHolder should solve this multithread issue
ReplyDeleteThanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java EE Training in Chennai. or learn thru Java EE Training in Chennai Students.
ReplyDeleteI’ve desired to post about something similar to this on one of my blogs and this has given me an idea. Cool Mat.
ReplyDeletepython Training institute in Pune
python Training institute in Chennai
python Training institute in Bangalore
Pleasant Tips..Thanks for Sharing….We keep up hands on approach at work and in the workplace, keeping our business pragmatic, which recommends we can help you with your tree clearing and pruning in an invaluable and fit way.
ReplyDeleteData Science Training in Indira nagar
Data Science training in marathahalli
Data Science Interview questions and answers
Data Science training in btm layout
Data Science Training in BTM Layout
Data science training in kalyan nagar
Thank you for allowing me to read it, welcome to the next in a recent article. And thanks for sharing the nice article, keep posting or updating news article.
ReplyDeletepython training in chennai
python course institute in chennai
ReplyDeleteWhoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
AWS Training in Bangalore | Best AWS Amazon Web Services…
Amazon Web Services (AWS) Training in Pune India
AWS Training | AWS Training and Certification | AWS online training
AWS Training in Bangalore cost| Aws training in Bangalore with placements
Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision.
ReplyDeleteAWS Training in pune
AWS Online Training
AWS Training in Bangalore
Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. aws training in chennai | aws training in annanagar | aws training in omr | aws training in porur | aws training in tambaram | aws training in velachery
ReplyDeleteit is really wonderful and awesome thus it is very much useful for me to understand many concepts. I like very much
ReplyDeletePython Training in Chennai
Python Training in Bangalore
Python Training in Hyderabad
Python Training in Coimbatore
Python Training
python online training
python flask training
python flask online training
Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
ReplyDeletejava training in chennai
java training in tambaram
aws training in chennai
aws training in tambaram
python training in chennai
python training in tambaram
selenium training in chennai
selenium training in tambaram
Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog.
ReplyDeleteoracle training in chennai
oracle training in omr
oracle dba training in chennai
oracle dba training in omr
ccna training in chennai
ccna training in omr
seo training in chennai
seo training in omr
Great post. Thanks for sharing such a useful blog.
ReplyDeleteArtificial Intelligence Course in Velachery
Artificial Intelligence Course in Chennai
ReplyDeleteGreat post. keep sharing such a worthy information.
AWS Training institute in Chennai