Reputation: 14031
I am using Spring Integration here.
I have a directory where files are being copied to by another service activator.
The files need to stay there until their status on the DB is processed
- then I need to move the files to the next directory where they will be sent (via SFTP) to their final destination.
I have a polling channel that fetches a list of files in the processed
status (from DB). Then I split the incoming list (each Message
now contains the name of the file I need to move to the next directory in its payload
.)
How do I tell the inbound-channel-adapter
to read only the given file (I have the full path to the file) from the defined directory and copy/move it to the next directory?
This is my config so far:
<!-- File Adapters: Inbound -->
<file:inbound-channel-adapter
id="filesInChannelAdapter"
filename-regex="/^#jsonPath(payload,'$.filename')$/" <<< this does not work
directory="${inbound.dir}" />
<!-- Service Activators -->
<int:service-activator input-channel="filesInChannelAdapter"
output-channel="filesOutChannelAdapter"
id="fileCopyActivator"
method="handleFile"
ref="fileCopyHandler"/>
<!-- File Adapters: Outbound -->
<file:outbound-channel-adapter
id="filesOutChannelAdapter"
preserve-timestamp="true"
delete-source-files="true"
directory="${outbound.dir}"/>
Is there a way to read a file in without having to poll a directory?
How else could I copy the file from directory A to B after querying its status from the DB? (via a REST endpoint)
Upvotes: 0
Views: 83
Reputation: 121282
The FileWritingMessageHandler
(<int-file:outbound-channel-adapter>
) can do that for you. So, you REST endpoint brings a file name, you check it state in DB, e.g. via <filter>
and then go to the <int-file:outbound-channel-adapter>
with the File
payload and Files.move()
will be performed for you.
Upvotes: 1