0

In my use case my itemWriter will write an XML to the filesystem, after which I want to insert the representation in a table.

public CompositeItemWriter<T> compositeItemWriter(){
    CompositeItemWriter writer = new CompositeItemWriter();
    writer.setDelegates(Arrays.asList(fileWriter(), dbWriter()));
    return writer;
}

If an object from the stream isn't properly saved to the file, it is ok to skip it using a skip policy, and I will probably save the failed objects somewhere in the form of a log.
However it is mandatory that the dbWriter does not write this entity to the db in case it happens.

So how can we use the composite writer to skip the second itemwriter in case the first one fails?

html_programmer
  • 18,126
  • 18
  • 85
  • 158

1 Answers1

0

It seems that the behaviour I want is the default, based on what I read on the following thread:

Spring-Batch How skip exceptions works for composite writers

I assumed that the itemWriters would run in parallel by default. Not sure why they don't, but it's perfect for my use case.

html_programmer
  • 18,126
  • 18
  • 85
  • 158