Search code examples
apache-camel

Making Properties Accesible from Camel Route


I'm new to camel and I'm trying to use property placeholders in a (YAML) route. However I can only access them if I create a custom CamelConfiguration, if I don't use it, it complains that it cannot find such property.

I know camel is reading the application.properties file because its getting its own configuration from there, but somehow the rest of the properties are not published into the context.

I'm running camel locally with camel-main.

My route is below.

- route:
    id: route-1579
    from:
      id: from-1606
      uri: timer
      parameters:
        period: "0"
        timerName: start
      steps:

        - bean:
            id: ReadFiles
            method: getExports({{azure.delta_path}},{{azure.full_path}})
            ref: reader
        - loop:
            id: loop-2f61
            steps:
              - log:
                  id: log-6422
                  logName: loggy
                  message: ${body}
            expression:
              simple:
                id: simple-f05c
                expression: ${body.size()}

Solution

  • Add a PropertiesComponent Bean like so:

    - beans:
        - builderMethod: ""
          constructors: {}
          name: properties
          properties:
            location: classpath:/application.properties
          type: org.apache.camel.component.properties.PropertiesComponent