2017-01-18 43 views
0

我有一個春天的整合文件,使用入站適配器讀取CouchDB的本地目錄中的一些文件,然後保存。我想最後刪除它。在我的屬性文件中,我使用了delete.source.files = true。但是,這似乎並不奏效。我在其他stackflow問題中讀到我可以使用ExpressionEvaluatingRequestHandlerAdvice。我用我的inboundchanneladapter,但它不起作用。刪除源文件Spring集成

<file:inbound-channel-adapter id="filesInput" expression= "headers['file_originalFile'].delete()?null:null" 
     directory="file:${incoming.path}/${tw.instance}" queue-size="8" 
     filename-pattern="*.json" prevent-duplicates="true" channel="filesIn" > 
     <int:poller id="poller" fixed-rate="${file.read.interval.millis}" 
      task-executor="pollerExecutor" /> 
    </file:inbound-channel-adapter> 

其他任何刪除方法?這個表達有什麼問題。我是春季整合的新手。提前致謝。

回答

0

首先,沒有對<file:inbound-channel-adapter>沒有expression選項。另一種情況是,該組件沒有任何選項可以刪除文件。由於此組件完全基於java.io.File對象,因此無需引入任何刪除功能,因爲簡單的File.delete()在任何下游地方都足夠了。

對,ExpressionEvaluatingRequestHandlerAdvice可以用於此事,但作爲<service-activator><request-handler-advice-chain>用於該couchdb操作。其onSuccessExpression選項可用於執行File.delete()

+0

我的問題是有3出站通道適配器 <文件:出站通道適配器ID = 「archiveFileWriter」 \t \t信道= 「filesIn」 \t \t目錄表達式=「'$ {archive.path} /${tw.instance}/'+ @ dirNameGenerator.yearMonthDayHour()「 \t \t delete-source-files =」$ {delete.source.files}「/> Light

+0

我在哪裏使用<請求處理程序-建議鏈>? – Light