Announcement Announcement Module
No announcement yet.
outbound-channel-adapter : Delete files after copying to output directory . Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • outbound-channel-adapter : Delete files after copying to output directory .

    Hi , i am using spring-integration-2.1.0 . I am copying the file using integration.xml . The code is as follows .

    <bean id="fileInChannel" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location">
    <bean id="fileHandler" class="com.kensho.dms.intg.FileCopyHandler" scope="singleton" />
    <file:inbound-channel-adapter id="inputSource" directory="file:${}" prevent-duplicates="false" channel="fileInputChannel" >
    <integrationoller id="filePoller" fixed-rate="10" />

    <integration:channel id="fileInputChannel" />

    <integration:chain input-channel="fileInputChannel" output-channel="fileProcessChannel" >
    <integration:service-activator ref="fileHandler" method="handleFile" />

    <integration:channel id="fileProcessChannel" />

    <file:outbound-channel-adapter id="staging" directory="${}" delete-source-files="true" channel="fileProcessChannel" />


    after copying the file i am deleting the souce file using following code .

    <file:outbound-channel-adapter id="staging" directory="${}" delete-source-files="true" channel="fileProcessChannel" />

    Till here every things works great . Now i want to check , if any duplicate file arrives in output directory then rename it . Any solution is welcome .

  • #2
    Assuming fileHandler creates a message with a payload of

    1. Make fileProcessChannel a <publish-subscribe-channel/>
    2. Make the first subscriber (order="1") a

    <service-activator ... "expression="new${}/'someOtherName')" />
    3. Make the outbound channel adapter the second subscriber (order="2")

    The result of the rename (true or false) will be discarded by sending it to nullChannel.
    Last edited by Gary Russell; Sep 13th, 2012, 08:11 AM.


    • #3
      My expression was wrong; I changed it to...

      But you might want to use a java class rather than an expression if you want more sophistication in the rename.