[英]Camel Spring DSL Call a method on bean once all all files in a directory have been processed
I am trying to achieve the following in Camel Spring DSL (Version 2.12.1). 我试图在Camel Spring DSL(2.12.1版)中实现以下目标。
indexer
bean indexer
bean处理每个文件 finalizeRepository
method on the indexer bean once all files have been processed finalizeRepository
方法 (Based on the answer supplied by Claus I have updated the code sample below with a working solution.) (基于克劳斯提供的答案,我已使用有效的解决方案更新了以下代码示例。)
<route>
<from uri="file:./dataToIndex" />
<bean ref="indexer" method="addDocument(${body}, ${headers.CamelFileNameOnly})" />
<when>
<simple>${headers.CamelBatchComplete} == true</simple>
<bean ref="indexer" method="finalizeRepository" />
</when>
</route>
If the header CamelBatchComplete
holds the value true
the method finalizeRepository
on the indexer
bean will be called. 如果标头
CamelBatchComplete
的值为true
,则将调用indexer
bean上的finalizeRepository
方法。 The header is set to true
once all documents in the dataToIndex
directory have been processed. 一旦处理了
dataToIndex
目录中的所有文档,标头就设置为true
。
The only thing I am not quite certain about is the definition of batch
. 我唯一不确定的是
batch
的定义。 Is a batch
determined based on what is found during a single polling event (eg if 1k files are found in a directory then this constitutes the batch), or a pattern of polling event (ie a series of successfull polls with items followed by a poll without any items is considered a batch
). 是一个
batch
的基础上确定什么是单轮询事件过程中发现的(例如,如果1K文件在目录中找到那么这构成批次),或轮询事件的模式(即项目,随后以投票一系列全成投票没有任何项目的项目视为batch
)。
The file component adds a header when its processing the last file in the batch. 文件组件在处理批处理中的最后一个文件时会添加标头。 You can use that to know when its the last and call the bean.
您可以使用它来知道何时最后一次调用bean。
This is done by other components which supports "batch" as you can find details here 这是由其他支持“批处理”的组件完成的,您可以在此处找到详细信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.