2015-12-22 63 views
1

我正在使用spring集成從s3讀取文件但是,這個工程,但我的本地目錄越來越滿我想在從s3處理文件後從本地目錄中刪除文件? 春天集成aws s3刪除本地文件

<bean id="credentials" class="org.springframework.integration.aws.core.BasicAWSCredentials"> 
     <property name="accessKey" value="${accessKey}"/> 
     <property name="secretKey" value="${secretKey}"/> 
    </bean> 



    <bean id="clientConfiguration" class="com.amazonaws.ClientConfiguration"> 
     <property name="proxyHost" value="${proxyHost}"/> 
     <property name="proxyPort" value="${proxyPort}"/> 
    <property name="preemptiveBasicProxyAuth" value="false"/> 
    </bean> 

    <bean id="s3Operations" class="org.springframework.integration.aws.s3.core.CustomC1AmazonS3Operations"> 
     <constructor-arg index="0" ref="credentials"/> 
     <constructor-arg index="1" ref="clientConfiguration"/> 
     <property name="awsEndpoint" value="s3.amazonaws.com"/> 
     <property name="temporaryDirectory" value="${temporaryDirectory}"/> 
     <property name="awsSecurityKey" value="${awsSecurityKey}"/> 
    </bean> 



    <!-- aws-endpoint="https://s3.amazonaws.com" --> 
    <int-aws:s3-inbound-channel-adapter aws-endpoint="s3.amazonaws.com" 
             bucket="${bucket}" 
             s3-operations="s3Operations" 
             credentials-ref="credentials" 
             file-name-wildcard="${fileNameWildcard}" 
             remote-directory="${remoteDirectory}" 
             channel="splitChannel" 
             local-directory="${localDirectory}" 
             accept-sub-folders="false" 
             delete-source-files="true" 
             archive-bucket="${archiveBucket}" 
             archive-directory="${archiveDirectory}"> 
    </int-aws:s3-inbound-channel-adapter> 

回答

1

看起來你正在尋找ExpressionEvaluatingRequestHandlerAdvice。請致電Retry and Moreexpression-advice-context.xml配置中有類似<property name="onSuccessExpression" value="payload.delete()" />的東西,以便在正確完成該過程後關注本地文件。

+0

謝謝Artem .But插入ExpressionEvaluatingRequestHandlerAdvice到上面顯示的int-aws所示的applicationcontext中:s3-inbound-channel-adapter – constantlearner

+0

在某個''下游。我確信你有'splitChannel'之後的東西。 –