在春季批次中,我有一个tasklet
和一个步骤(reader
,processor
,writer
)
我正在处理大块的事情。
tasklet
下载文件。该步骤正在处理该文件中的行。
我在处理器中添加了验证逻辑:
@Override
public MyObject process(MyOjbect item) throws Exception {
{
...
boolean result=validateObject(item);
if (result)
{
return item;
}
else
{
return null;
}
}
我的作家忽略了空格:
public void write(List<? extends MyObject> items) throws Exception {
for (MyObjectitem : items) {
try {
if (item != null) {
....
}
} catch (Exception e) {
logger.error("Error writing item=" + item.toString(), e);
}
}
}
问题是我想计算Ignored / null项的数量,并在作业结束时将其暴露在外面。
任何想法怎么做? 我将并行完成许多工作,因此必须考虑多线程。
谢谢你, 射线
这就是我的处理器的定义方式:
@Bean
public Step processSnidFileStep() {
return stepBuilderFactory.get("processSnidFileStep")
.<MyObject, MyObject>chunk(numOfProcessingChunksPerFile)
.reader(reader(OVERRIDDEN_BY_EXPRESSION,OVERRIDDEN_BY_EXPRESSION))
.processor(asyncItemProcessor())
.writer(asyncItemWriter())
.listener(logProcessListener())
.throttleLimit(20)
.build();
}
@Bean
public AsyncItemProcessor asyncItemProcessor() {
AsyncItemProcessor<MyObject, MyObject> asyncItemProcessor = new AsyncItemProcessor();
asyncItemProcessor.setDelegate(processor(OVERRIDDEN_BY_EXPRESSION, OVERRIDDEN_BY_EXPRESSION, OVERRIDDEN_BY_EXPRESSION,
OVERRIDDEN_BY_EXPRESSION, OVERRIDDEN_BY_EXPRESSION, OVERRIDDEN_BY_EXPRESSION, OVERRIDDEN_BY_EXPRESSION, OVERRIDDEN_BY_EXPRESSION,0));
asyncItemProcessor.setTaskExecutor(infrastructureConfigurationConfig.taskProcessingExecutor());
return asyncItemProcessor;
}