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

Add a helper method to easily add a route

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0-M2
    • Component/s: None
    • Labels:
      None
    • Estimated Complexity:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: