0
votes

I have a spring integration file that using inbound adapter reads some files from local directory and then stores it in couchdb. I would want to delete it in the end. In my properties file , I used delete.source.files=true. However, this doesnt seem to work. I read in other stackflow questions that i could use ExpressionEvaluatingRequestHandlerAdvice. I used it with my inboundchanneladapter, but it does not work.

<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>

any other way of deleting it? what is wrong with the expression. I'm new to spring integration. thanks in advance.

1

1 Answers

1
votes

First of all there is no expression option on the <file:inbound-channel-adapter>. Another case that there is really no any options for that component to delete files. Since this component is fully based on the java.io.File objects there is no reason to introduce any delete functionality since the simple File.delete() is enough in any downstream place.

Right, ExpressionEvaluatingRequestHandlerAdvice can be used on the matter but as a <request-handler-advice-chain> on the <service-activator> for that couchdb operation. Its onSuccessExpression option can be use to perform File.delete().