317.2. Camel 스키마 추가


Camel 1.x의 경우 다음 네임스페이스를 사용해야 합니다.

http://activemq.apache.org/camel/schema/spring
Copy to Clipboard Toggle word wrap

다음 스키마 위치:

http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
Copy to Clipboard Toggle word wrap

schemaLocation 선언에 Camel을 추가해야 합니다.

http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
Copy to Clipboard Toggle word wrap

XML 파일은 다음과 같습니다.

<beans xmlns="http://www.springframework.org/schema/beans"
       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.xsd
          http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
Copy to Clipboard Toggle word wrap

317.2.1. camel 사용: namespace

또는 XML 선언에서 camel XSD를 참조할 수 있습니다.

xmlns:camel="http://camel.apache.org/schema/spring"
Copy to Clipboard Toggle word wrap
  1. 선언은 다음과 같습니다.
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
Copy to Clipboard Toggle word wrap
  1. 그런 다음 camel: namespace 접두사를 사용하고 인라인 네임스페이스 선언을 생략할 수 있습니다.
<camel:camelContext id="camel5">
  <camel:package>org.apache.camel.spring.example</camel:package>
</camel:camelContext>
Copy to Clipboard Toggle word wrap

317.2.2. Spring을 사용한 고급 구성

Spring을 사용한 CamelContext의 고급 구성에서자세한 내용을 참조하십시오.

$# Java 코드 사용

Java 코드를 사용하여 RouteBuilder 구현을 정의할 수 있습니다. 이러한 값은 Spring에서Beans로 정의될 수 있으며, 다음과 같이 camel 컨텍스트에서 참조할 수 있습니다.

317.2.3. 사용

Camel은 또한 지정된 패키지의 경로를 자동으로 검색하고 초기화할 수 있는 강력한 기능을 제공합니다. 이는 Spring 컨텍스트 정의의 camel 컨텍스트에 태그를 추가하여 구성된 것으로, RouteBuilder 구현을 위해 재귀적으로 검색할 패키지를 지정합니다. 1.X에서 이 기능을 사용하려면 검색해야 하는 쉼표로 구분된 패키지 목록을 지정하는 <package></package> 태그가 필요합니다.

  <camelContext xmlns="http://camel.apache.org/schema/spring">
    <package>org.apache.camel.spring.config.scan.route</package>
  </camelContext>
Copy to Clipboard Toggle word wrap

경고: 패키지 이름을 org.apache.camel 또는 이 하위 패키지로 지정할 때는 주의하십시오. 이로 인해 Camel이 문제를 일으킬 수 있는 경로의 자체 패키지에서 검색할 수 있습니다.

INFO:* 이미 인스턴스화된 클래스*를 무시합니다. <package> 및 <packageScan>은 Spring 등에 의해 이미 생성된 클래스를 건너뜁니다. 따라서 경로 빌더를 SpringBean 태그로 정의하면 해당 클래스를 건너뜁니다. < routeBuilder ref="theBeanId"/ > 또는 < contextScan > 기능을 사용하여 해당Beans를 포함할 수 있습니다.

317.2.4. 사용

Camel 2.0에서는 경로 일치와 유사한 경로 일치를 사용하여 검색된 경로 클래스를 선택적으로 포함 및 제외할 수 있도록 확장되었습니다. Spring에서는 <packageScan/> 태그를 추가하여 지정합니다. 태그는 하나 이상의 '패키지' 요소(예: 1.x와 유사)를 포함해야 하며 선택적으로 검색된 클래스의 정규화된 이름에 적용할 패턴을 지정하는 하나 이상의 '포함' 또는 'excludes' 요소를 포함해야 합니다.

  <camelContext xmlns="http://camel.apache.org/schema/spring">
    <packageScan>
      <package>org.example.routes</package>
      <excludes>**.*Excluded*</excludes>
      <includes>**.*</includes>
    </packageScan>
  </camelContext>
Copy to Clipboard Toggle word wrap

exclude 패턴은 include 패턴 전에 적용됩니다. 포함 또는 제외 패턴이 정의되지 않은 경우 패키지에서 검색되는 모든 Route 클래스가 반환됩니다.

위의 예에서 camel은 모든 'org.example.routes' 패키지 및 RouteBuilder 클래스에 대한 하위 패키지를 스캔합니다. 검사에서 'excluded' 하위 패키지에서 org.example.routes라는 두 개의 RouteBuilder 및 'MyExcludedRoute'를 찾습니다. 각 클래스의 정규화된 이름은 추출(org.example.routes.MyRoute, org.example.routes.excluded.MyExcludedRoute)이며 포함 및 제외 패턴이 적용됩니다.

제외 패턴 *.*Excluded 는 fqcn 'org.example.routes.excluded.MyExcludedRoute' 및 veto camel과 일치하게 됩니다.

커버 아래에서는 다음과 같이 일치하는 Spring의ECDHEP ECDHEnMatcher 구현을 사용하고 있습니다.

? matches one character
* matches zero or more characters
** matches zero or more segments of a fully qualified name
Copy to Clipboard Toggle word wrap

예를 들면 다음과 같습니다.

*excluded 는 org.simple.Excluded, org.apache.camel.00000000ExcludedRoute 또는 org.example.RouteWhichIsExcluded와 일치합니다.

*.?? 포함됨은 org.simple.IncludedRoute, org.simple.Excluded와 일치하지만 org.simple.PrecludedRoute와 일치하지 않음

317.2.5. contextScan 사용

Camel 2.4에서 사용 가능

Camel이 경로 빌더 인스턴스의 Spring ApplicationContext 와 같은 컨테이너 컨텍스트를 스캔하도록 허용할 수 있습니다. 이를 통해 Spring < component-scan > 기능을 사용할 수 있으며 검사 프로세스에서 Spring에서 생성한 모든 RouteBuilder 인스턴스를 Camel을 선택할 수 있습니다.

이를 통해 Spring @Component 를 사용하여 경로에 주석을 달고 Camel에 포함된 경로를 지정할 수 있습니다.

@Component
public class MyRoute extends SpringRouteBuilder {

    @Override
    public void configure() throws Exception {
        from("direct:start").to("mock:result");
    }
}
Copy to Clipboard Toggle word wrap

위에서 언급한 대로 < packageScan> 문서에서 언급한 것처럼 ANT 스타일을 포함 및 제외할 수도 있습니다.

맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat