Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9882

Support importing Camel XML configuration files in Camel CDI

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.18.0
    • camel-cdi
    • None
    • Unknown

    Description

      So that user can use their existing Camel XML files with CDI or use Camel XML for configuring their Camel contexts.

      For example, given the following Camel XML:

      <camelContext id="test" errorHandlerRef="error-handler"
                    xmlns="http://camel.apache.org/schema/spring">
      
          <errorHandler id="error-handler"
                        type="LoggingErrorHandler"
                        logName="error"
                        level="WARN"/>
      
          <route>
              <from uri="direct:inbound"/>
              <choice>
                  <when>
                      <simple>${body} contains 'exception'</simple>
                      <throwException ref="failure"/>
                  </when>
                  <otherwise>
                      <transform>
                          <simple>Response to ${body}</simple>
                      </transform>
                      <to uri="mock:outbound"/>
                  </otherwise>
              </choice>
          </route>
      
      </camelContext>
      

      And following bean:

      @Named
      @Produces
      Exception failure = new CamelException("failure message!");
      

      The Camel XML elements with an id attributes (errorHandler in the example) get deployed as CDI beans and vice-versa the ref attributes can refer to CDI beans (@Named("failure") in the example).

      The current proposition is to expose an annotation that the developer can use on any CDI bean to declare the Camel XML files to import in her/his Camel CDI application, e.g.:

      @ImportResource("imported-context.xml")
      class MyCamelCdiBean {
      }
      

      Attachments

        Activity

          People

            antonin.stefanutti Antonin Stefanutti
            antonin.stefanutti Antonin Stefanutti
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: