lundi 20 avril 2015

how to polling int:gateway to start int-ftp:outbound-gateway?

firstly thanks for attention
i define outbound-gateway ftp adapter to run ftp command on target server,my goal is run periodically ls,mv,get,... commands on server and run task on batch library job, my code is:

   <bean id="ftpClientFactory1" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    <property name="host" value="127.0.0.1"/>
    <property name="port" value="21"/>
    <property name="username" value="banks_reader"/>
    <property name="password" value="123456"/>
    <property name="clientMode" value="2"/>
    <property name="fileType" value="2"/>

</bean>

<int:gateway id="gw" service-interface="ir.ali.util.ToFtpFlowGateway"
             default-request-channel="inbound1"/>
<int:channel id="inbound1"/>

<int-ftp:outbound-gateway id="gateway1"
                          session-factory="ftpClientFactory1"
                          request-channel="inbound1"
                          reply-channel="outbound"
                          reply-timeout="777"
                          auto-create-local-directory="false"
                          auto-startup="true"
                          filename-pattern="*"
                          remote-file-separator="/"
                          command="ls"
                          command-options="-dirs -R"
                          expression="payload"
                          mput-regex=".*"

        >
</int-ftp:outbound-gateway>
<int:channel id="outbound">
    <int:interceptors>
        <int:wire-tap channel="logger"/>
    </int:interceptors>
</int:channel>
<int:channel id="outboundJobRequestChannel"/>
<int:logging-channel-adapter id="logger" log-full-message="true" />

<int:transformer input-channel="outbound"  output-channel="outboundJobRequestChannel">
    <bean class="ir.ali.configuration.FileMessageToJobRequest"/>
</int:transformer>

<int:splitter id="splitter" input-channel="outbound" output-channel="ftpChannel"/>

<int:channel id="ftpChannel">
    <int:queue/>
</int:channel>

and in Application Class send message to inbound1 channel and start int-ftp:outbound-gateway the code is:

 final ToFtpFlowGateway toFtpFlow = ctx.getBean(ToFtpFlowGateway.class);
    try  {
        List<Boolean> rmResults = toFtpFlow.lsGetAndRmFiles("/");
    } catch (Exception e) {
        e.printStackTrace();
    }

it's worked correctly , the problem is that i needed run periodically ls and mv ,... recursive command on the server,how to run toFtpFlow.lsGetAndRmFiles("/"); periodically to start int-ftp:outbound-gateway ?

Aucun commentaire:

Enregistrer un commentaire