sftp:当我使用CompositeFileListFilter时,带有zookeeper的inbound-streaming-channel-adapter无法正常工作

时间:2017-11-08 09:02:39

标签: spring-integration apache-zookeeper spring-integration-sftp

我使用了sftp:inbound-streaming-channel-adapter和zookeeper。但它给了我异常:java.lang.ClassCastException:com.jcraft.jsch.ChannelSftp $ LsEntry无法强制转换为java.io.File。我使用以下代码

<int-sftp:inbound-streaming-channel-adapter
    id="sftpAdapter" channel="receiveChannel"
    session-factory="cachingSessionFactory" 
    remote-file-separator="/" remote-directory-expression="'${ftpServerLoc}'" filter="compositeFilter"
    auto-startup="true">
    <int:poller fixed-rate="${pollarInterval}"
        max-messages-per-poll="1" />
</int-sftp:inbound-streaming-channel-adapter>

  <beans:bean id="compositeFilter"
    class="org.springframework.integration.file.filters.CompositeFileListFilter">
    <beans:constructor-arg>
        <beans:list>
             <beans:bean
                class="org.springframework.integration.file.filters.RegexPatternFileListFilter">
                 <beans:constructor-arg value="^.*\.(dat|DAT)$" />

            </beans:bean>
            <beans:bean
                class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter">
                <beans:constructor-arg name="store"
                    ref="metadataStore" />
                <beans:constructor-arg value="" />
            </beans:bean>
        </beans:list>
    </beans:constructor-arg>
</beans:bean>

1 个答案:

答案 0 :(得分:1)

IF EXISTS ( SELECT 1 FROM TableName WHERE ID = ID_from_form_field ) BEGIN UPDATE TableName SET Name = 'Name_from_form_field', UniqueNumber = uniquenumber_from_form_field WHERE ID = ID_from_form_field; END ELSE BEGIN INSERT INTO TableName (Name, UniqueNumber ) VALUES ('Name_from_form_field', uniquenumber_from_form_field ); END 应为org.springframework.integration.file.filters.RegexPatternFileListFilter

你所适用的org.springframework.integration.sftp.filters.SftpRegexPatternFileListFilter; sftp版本适用于java.io.File(Jsch表示远程文件)。