2017-10-25 1 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 인증서를 가져와야 할 것입니다. 원격 파일 구성은 엔드 포인트에서 매개 변수로 옵션으로 선언되어야합니다.

<?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을 생성하고이를 참조 용으로 낙타 종점에 전달할 수 있습니다.

<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의 예를 제공 할 수 있습니까? –