I want to be able to delete an item while processing it if it fits a specific logic. For example, if the item doesn't contain a value I'm looking for, I don't want to that item to be written out to the file.
I'm currently using a class which implements ItemProcessor<T,T>
.
Do I just return null?
We can handle it via a custom Dummy Object. And just use the below when required to skip the record in the reader : return MyClass. getDummyyClassObject();
An ItemProcessor is simple. Given one object, transform it and return another. The provided object may or may not be of the same type. The point is that business logic may be applied within the process, and it is completely up to the developer to create that logic. An ItemProcessor can be wired directly into a step.
Yes, that could be done, indeed.
Chunk oriented processing refers to reading the data one at a time and creating 'chunks' that are written out within a transaction boundary. Once the number of items read equals the commit interval, the entire chunk is written out by the ItemWriter , and then the transaction is committed.
Return null from the processor like below.
public class ExceptionRecordValidator implements
ItemProcessor<yourDTO, yourDTO>{
@Override
public yourDTO process(
yourDTOitem) throws Exception {
if(your requested value found){
return yourDTO ;
}else{
return null;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With