我构建了一个camel路由,使用camel bindy对csv文件进行解码,并将内容写入数据库。这与文件为空时完全不同,从外观上看,这将发生很多次。该文件确实包含csv报头,但没有相关数据,例如:
CODE;CATEGORY;PRICE;在这种情况下,引发以下错误:
java.lang.IllegalArgumentException: No records have been defined in the CSV我尝试将allowEmptyStream = true添加到用于解编组的bindy对象中。然而,由于同样的错误出现,这似乎不起多大作用。
任何关于如何跳过处理这些空文件的想法都是非常欢迎的。
发布于 2022-03-17 09:09:49
在您的用例中,选项allowEmptyStream必须在Bindy DataFormat级别设置为true,如下所示:
BindyCsvDataFormat bindy = new BindyCsvDataFormat(SomeModel.class);
bindy.setAllowEmptyStream(true);
from("file:some/path")
.unmarshal(bindy)
// The rest of the routehttps://stackoverflow.com/questions/71497688
复制相似问题