聚合后处理错误

时间:2013-06-24 17:15:29

标签: error-handling apache-camel aggregation

我正在从CSV文件中读取一些行,将它们转换为业务对象,将这些行聚合到批处理中,并将生成的聚合传递给bean,这可能会抛出PersistenceException。 不知何故这样: from(file:inputdir).split().tokenize("\n").bean(a).aggregate(constant(true), new AbstractListAggregationStrategy(){...}).completionSize(3).bean(b)

我有onException(Exception.class).handled(true).to("file:failuredir").log()。如果bean(a)上发生异常,则会按预期处理所有内容:inputdir/input.csv中的错误行会写入failuredir/input.csv。 现在,如果bean(b)失败,Camel似乎无法重建原始消息:

message.org.apache.camel.component.file.GenericFileOperationFailedException: Cannot store file: target/failure/ID-myhostname-34516-1372093690069-0-7

尝试了各种尝试来实现这一点,比如使用HawtDBAggregationRepository,在useOriginalMessage切换onException并在我的AggregationStrategy中传播回异常,我的想法不合时宜。

如何bean(b)可以看到与bean(a)相同的行为?

1 个答案:

答案 0 :(得分:1)

聚合器是一种有状态的EIP模式,因此当它发出消息时,它就是一个新的Exchange。因此bean(b)无法访问来自文件路由的原始消息。