0

I built a camel route that unmarshals a csv file using camel bindy and writes the contents to a database. This works perfectly apart from when the file is empty, which by the looks of it will happen a lot. The file does contain csv headers, but no relevant data e.g.:

CODE;CATEGORY;PRICE;

In this case the following error is thrown:

java.lang.IllegalArgumentException: No records have been defined in the CSV

I tried adding allowEmptyStream = true to the bindy object that I use for unmarshalling. This however does not seem to do much, as the same error appears.

Any ideas on how to skip processing these empty files is very welcome.

Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122
lbma
  • 132
  • 8

1 Answers1

0

In your use case, the option allowEmptyStream must be set to true at Bindy DataFormat level, as next:

BindyCsvDataFormat bindy = new BindyCsvDataFormat(SomeModel.class);
bindy.setAllowEmptyStream(true);

from("file:some/path")
    .unmarshal(bindy)
    // The rest of the route
Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122