Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Camel CDI component provides auto-configuration for Apache Camel using CDI as dependency injection framework based on the convention-over-configuration principle. It auto-detects Camel routes available in the application and provides beans for common Camel primitives like EndpointProducerTemplate or TypeConverter. It implements standard Camel bean integration so that Camel annotations like @Consume@Produce and @PropertyInject can be used seamlessly in CDI beans. Besides, it bridges Camel events (e.g. RouteAddedEvent, CamelContextStartedEvent or ExchangeCompletedEvent) as CDI events and provides a CDI events endpoint that can be used to consume / produce CDI events from / to Camel routes.

...

Similarly, the @Default qualifier can be used to observe Camel events for the default Camel context if multiples contexts exist, e.g.:

 

Code Block
languagejava
void onExchangeCompleted(@Observes @Default ExchangeCompletedEvent event) {
    // Called after the exchange 'event.getExchange()' processing has completed
}

In that example, if no qualifier is specified, the @Any qualifier is implicitly assumed, so that corresponding events for all the Camel contexts get received.

Note that the support for Camel events translation into CDI events is only activated if observer methods listening for Camel events are detected in the deployment, and that per Camel context.

CDI events endpoint

 

Auto-configured type converters

CDI beans annotated with the @Converter annotation are automatically registered into the deployed Camel contexts, e.g.:

Code Block
languagejava
@Converter
public class MyTypeConverter {

    @Converter
    public Output convert(Input input) {
        //...
    }
}

Note that CDI injection is supported within the type converters.

Configuration properties

 

Camel bean integration

 

Supported containers

 

See Also

...