2017-10-25 2 views
1

私は、SFTPエンドポイントでApache Camelを使用している従来のアプリケーションを開発中です。Camelコンテキストは、Spring Xml Dslを使用して定義されます。Apache Camel SFTPConfiguration with Spring XML

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:camel="http://camel.apache.org/schema/spring" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> 

    <camel:camelContext id="myCtx" errorHandlerRef="eventDLQ" 
        xmlns="http://camel.apache.org/schema/spring" 
        autoStartup="true"> 

    <camel:endpoint id="sftp1" uri="sftp://[email protected]"/> 
    <camel:endpoint id="sftp2" uri="sftp://[email protected]"/>            

</camel:camelContext> 
</beans> 

私はSFTPConfigurationオブジェクト を使用してキャメルSFTPを設定する必要がありますが、私は春を使用していて、それを配線する方法がわかりません。

XMLファイルでSpringを使用してBeanを作成するだけで、Camelが自動検出できますか?

答えて

1

ルートが同じスコープで利用できる場合、つまり、あなたのケースで同じコンテキストで利用できる場合は、はい。 SFTPを使用している場合は、インポートするSFTP証明書をjavaキーストアでインポートする必要があることをご存じでしょうか。リモートファイル設定は、エンドポイントのパラメータとしてオプションとして宣言する必要があります。

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:camel="http://camel.apache.org/schema/spring" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> 

    <camel:camelContext id="myCtx" errorHandlerRef="eventDLQ" 
        xmlns="http://camel.apache.org/schema/spring" 
        autoStartup="true"> 

    <camel:endpoint id="sftp1" uri="sftp://[email protected]"/> 
    <camel:endpoint id="sftp2" uri="sftp://[email protected]"/>            

    <route> 
     <from ref="sftp1"/> 
     <to uri="mock:result"/> 
    </route> 

    <route> 
     <from ref="sftp2"/> 
     <to uri="mock:result"/> 
    </route> 
</camel:camelContext> 
</beans> 

beanを作成して、camel-endpointにも参照にも渡すことができます。

<bean class="org.apache.camel.component.file.remote.SftpConfiguration" id="sftpConfig"> 
    <property name="jschLoggingLevel" value="WARN"/> 
    <property name="strictHostKeyChecking" value="no"/> 
</bean> 

注:あなたはこの中で利用できるすべてのオプションを使用することができます - Link

<bean class="org.apache.camel.component.file.remote.SftpEndpoint" id="sftpEndpoint"> 
    <property name="configuration" ref="sftpConfig" /> 
</bean> 

私はあなたがFTPCompnent srcを参照し、それに応じて、それにsftpEndpoint参照を渡すことができます使用しているラクダのバージョンを確認していません。

+0

SftpBeanConfigurationの例を提供できますか? –