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

Add a helper method to easily add a route

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0-M2
    • None
    • None
    • Unknown

    Description

      Using the following method in `ModelCamelContext`

      default void addRoute(ThrowingConsumer<RouteBuilder, Exception> rbc) throws Exception {
          addRoutes(new RouteBuilder() {
              @Override
              public void configure() throws Exception {
                  rbc.accept(this);
              }
          });
      }
      

      we can simplify blocks such as

      new RouteBuilder() {
          @Override
          public void configure() throws Exception {
              from(u).to("reactive-streams:" + uuid);
          }
      }.addRoutesToCamelContext(context);
      

      into

      context.adapt(ModelCamelContext.class).addRoute(rb -> 
          rb.from(u).to("reactive-streams:" + uuid));
      

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            gnodet Guillaume Nodet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: