59.9. Camel 이벤트를 CDI 이벤트로


Camel 2.17로 사용 가능

Camel은 Camel 컨텍스트, 서비스, 경로 및 교환 이벤트를 수신 대기하기 위해 서브스크립션할 수 있는 관리 이벤트 세트를 제공합니다. Camel CDI는 이러한 Camel 이벤트를 CDI 관찰 자 방법 을 사용하여 관찰할 수 있는 CDI 이벤트로 원활하게 변환합니다. 예를 들면 다음과 같습니다.

void onContextStarting(@Observes CamelContextStartingEvent event) {
    // Called before the default Camel context is about to start
}
Copy to Clipboard Toggle word wrap

Camel 2.18부터 특정 경로(RouteAddedEvent,RouteStartedEvent,RouteStoppedEventRouteRemovedEvent)에 대한 이벤트를 확인할 수 있습니다. 예를 들면 다음과 같습니다.

from("...").routeId("foo").to("...");

void onRouteStarted(@Observes @Named("foo") RouteStartedEvent event) {
    // Called after the route "foo" has started
}
Copy to Clipboard Toggle word wrap

CDI 컨테이너에 여러 Camel 컨텍스트가 있는 경우 @ContextName 와 같은 Camel 컨텍스트 빈 한정자를 사용하여 관찰자 메서드 확인을 관찰자 확인에 지정된 대로 특정 Camel 컨텍스트로 구체화할 수 있습니다. 예를 들면 다음과 같습니다. http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#observer_resolution

void onRouteStarted(@Observes @ContextName("foo") RouteStartedEvent event) {
    // Called after the route 'event.getRoute()' for the Camel context 'foo' has started
}
 
void onContextStarted(@Observes @Manual CamelContextStartedEvent event) {
    // Called after the the Camel context qualified with '@Manual' has started
}
Copy to Clipboard Toggle word wrap

마찬가지로 @Default 한정자를 사용하여 여러 컨텍스트가 있는 경우 기본 Camel 컨텍스트에 대한 Camel 이벤트를 관찰할 수 있습니다. 예를 들면 다음과 같습니다.

void onExchangeCompleted(@Observes @Default ExchangeCompletedEvent event) {
    // Called after the exchange 'event.getExchange()' processing has completed
}
Copy to Clipboard Toggle word wrap

이 예에서는 한정자를 지정하지 않으면 @Any 한정자가 암시적으로 가정되므로 모든 Camel 컨텍스트에 대한 해당 이벤트가 수신됩니다.

Camel 이벤트를 CDI 이벤트로 변환하는 지원은 배포에서 Camel 이벤트를 수신하는 관찰자 메서드 및 Camel 컨텍스트별로 감지되는 경우에만 활성화됩니다.

맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

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

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

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

Red Hat 소개

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

Theme

© 2025 Red Hat