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

Route Template local beans

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.10.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Now that we have route templates and kamelets, we should explore the option to have route local beans in addition to route local properties. This would be very useful when dealing with EIPs or endpoints that require specific beans.

      As example, assuming I have the following template:

      routeTemplate()
        .from("direct:start")
        .to("aws2-s3:...?amazonS3Client=#myClient")
      

      Then myClient need to be created at global scope and there's no way to create one that is specific for the template.

      We should provide something like:

      routeTemplate()
          .templateParameter("region")
          .templateParameter("bucket")
          .configure((RouteTemplateContext context) -> { 
              // the lambda mechanism here is used as illustration
              // purpose to stress the fact that the materialization
              // of beans should be delayed till the route is reified
              context.bind(
                  "myClient", 
                  S3Client.builder()
                      .region(context.getProperty("region"))
                      .build()
              );
          })
          .from("direct:start")
          .to("aws2-s3:{{bucket}}?amazonS3Client=#myClient")
      

      So when the route is materialized, the configure method is invoked, the myClient bean is registered to the current template context and retrieved by the reifier to materialize the route.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                davsclaus Claus Ibsen
                Reporter:
                lb Luca Burgazzoli
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: