Reputation: 137
I'm kind of having issues on implementing certain functionality and I'm noticing some inconsistencies when I drop files.
1) When I drop multiple files, sometimes not all files get transferred to the correct directory.
2) Sometimes the service activator hits before the file transfer happens by the outbound adapter.
3) Sometimes it stalls with .moving.
a) So by looking at the code below, is it correctly setup?
b) How can i make sure the source files are deleted before the service activator hits.
c) Is the transactional code necessary?
<!-- Adapter for reading files in the incoming directory -->
<int-file:inbound-channel-adapter id="incomingFileAdapter"
channel="fileInputChannel"
prevent-duplicates="false"
scanner="recursiveDirectoryScanner"
filename-regex="^.*\.(?i)(avi|divx|xvid|flv|f4v|mkv|m1v|m2v|m4v|mpeg|mpg|mp4|mov|vob|wmv|asf|ts|mxf)$"
directory="${file.listener.path.incoming}">
<int:poller id="filePoller" default="true" max-messages-per-poll="5" fixed-rate="5000">
<int:transactional transaction-manager="pseudoTransactionManager" />
</int:poller>
</int-file:inbound-channel-adapter>
<!-- Adapter for writing files to the processed directory -->
<int-file:outbound-channel-adapter id="processedFileAdapter"
mode="REPLACE"
channel="fileInputChannel"
delete-source-files="true"
auto-create-directory="true"
order="1"
directory-expression="@dynamicDirectoryGenerator.generateDirectory(payload)" />
<int:service-activator
input-channel="fileInputChannel"
output-channel="nullChannel"
order="2"
ref="fileInputActivator"
method="processMessage"/>
<bean id="fileInputActivator" class="com.nfl.dm.shield.ingestion.file.activator.FileInputActivator" />
<bean id="recursiveDirectoryScanner" class="org.springframework.integration.file.RecursiveLeafOnlyDirectoryScanner" />
<bean id="dynamicDirectoryGenerator" class="com.nfl.dm.shield.ingestion.file.dynamic.DynamicDirectoryGenerator" />
<bean id="pseudoTransactionManager" class="org.springframework.integration.transaction.PseudoTransactionManager" />
Upvotes: 2
Views: 1188
Reputation: 174484
a) Since you don't have a declaration for fileInputChannel
, it's a DirectChanel
which means the messages will alternately go to the outbound adapter and service activator.
Declare it as a <publish-subscribe-channel/>
and each file will go to both subscribers (based on order
).
b) It's not clear what you mean since you want to send the file to the service, why do you want it deleted before it gets there? If you do mean that then you can add a <request-handler-advice-chain/>
to the file adapter with an ExpressionEvaluatingRequestHandlerAdvice. See the retry-and-more sample for an example of how to use that advice.
c) No, the pseudo transaction is not necessary since you are not taking any action on success or failure.
Upvotes: 1