1
votes

I'd like to archive files that come in on a directory based on \name\date structure - so even every day the directory will change. Any suggestions appreciate.

I'm was on track to create a file outbound-gateway where the directory is dynamic, where the header is enriched with a method that generates the path of the directory.

I was thinking of something like this

<file:outbound-gateway id="archive" request-channel="input"
reply-channel="channel" directory="@Header[archiveLocation]}"
mode="REPLACE" delete-source-files="true">
</file:outbound-gateway>

But it doesn't seem to be the way to do it.

Based on previous related answers, I'm familiar with the samples at https://github.com/spring-projects/spring-integration-samples/blob/master/advanced/dynamic-ftp/src/main/resources/META-INF/spring/integration/dynamic-ftp-outbound-adapter-context.xml

My concern of doing it this way is, would there be any resource issues if I need to create tens, or hundreds of different outbound-gateway?

Since I can put the data in the header, is there an easier way to do it. Or is the directory field set at context initialization, and cannot be dynamic?

Thanks

1

1 Answers

1
votes

After finally creating an account on Stack Overflow all these years to post a question, found the answer later. I can use directory-expression.

<file:outbound-gateway id="archive" request-channel="input"
reply-channel="channel" directory-expression="headers.archiveLocation"
mode="REPLACE" delete-source-files="true">
</file:outbound-gateway>