org.apache.camel.Route Java Examples

The following examples show how to use org.apache.camel.Route. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RuntimeTest.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
@Test
void testLoadMultipleRoutes() throws Exception {
    runtime.addListener(new ContextConfigurer());
    runtime.addListener(RoutesConfigurer.forRoutes("classpath:r1.js", "classpath:r2.mytype?language=js"));
    runtime.addListener(Runtime.Phase.Started, r -> {
        CamelContext context = r.getCamelContext();
        List<Route> routes = context.getRoutes();

        assertThat(routes).hasSize(2);
        assertThat(routes).anyMatch(p -> ObjectHelper.equal("r1", p.getId()));
        assertThat(routes).anyMatch(p -> ObjectHelper.equal("r2", p.getId()));

        runtime.stop();
    });

    runtime.run();
}
 
Example #2
Source File: FlipRoutePolicy.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
public void onExchangeDone(Route route, Exchange exchange) {
    // decide which route to stop and start
    // basically we should flip the two routes
    String stop = route.getId().equals(name1) ? name1 : name2;
    String start = route.getId().equals(name1) ? name2 : name1;

    CamelContext context = exchange.getContext();
    try {
        // force stopping this route while we are routing an Exchange
        // requires two steps:
        // 1) unregister from the inflight registry
        // 2) stop the route
        context.getInflightRepository().remove(exchange);
        context.stopRoute(stop);
        // then we can start the other route
        context.startRoute(start);
    } catch (Exception e) {
        // let the exception handle handle it, which is often just to log it
        getExceptionHandler().handleException("Error flipping routes", e);
    }
}
 
Example #3
Source File: FlipRoutePolicy.java    From camelinaction with Apache License 2.0 6 votes vote down vote up
@Override
public void onExchangeDone(Route route, Exchange exchange) {
    // decide which route to stop and start
    // basically we should flip the two routes
    String stop = route.getId().equals(name1) ? name1 : name2;
    String start = route.getId().equals(name1) ? name2 : name1;

    CamelContext context = exchange.getContext();
    try {
        // force stopping this route while we are routing an Exchange
        // requires two steps:
        // 1) unregister from the inflight registry
        // 2) stop the route
        context.getInflightRepository().remove(exchange);
        context.stopRoute(stop);
        // then we can start the other route
        context.startRoute(start);
    } catch (Exception e) {
        // let the exception handle handle it, which is often just to log it
        getExceptionHandler().handleException("Error flipping routes", e);
    }
}
 
Example #4
Source File: TestReturnValueFromFlowable.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #5
Source File: SimpleProcessTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #6
Source File: CamelVariableTransferTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #7
Source File: SimpleProcessTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #8
Source File: CamelVariableBodyMapTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #9
Source File: EmptyProcessTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #10
Source File: AsyncProcessTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #11
Source File: SimpleSpringProcessTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #12
Source File: IntegrationActivityTrackingPolicy.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
public void onExchangeBegin(Route route, Exchange exchange) {
    if (tracker == null) {
        return;
    }

    tracker.startTracking(exchange);
}
 
Example #13
Source File: AsyncPingTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #14
Source File: ParallelProcessTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@AfterEach
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #15
Source File: EmptyProcessTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #16
Source File: CdiAsyncPingTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #17
Source File: SingleMessageRoutePolicy.java    From funktion-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public void onExchangeBegin(Route route, Exchange exchange) {
    super.onExchangeBegin(route, exchange);

    LOG.info("Exchange Begin for route " + route.getId() +
            " exchange: " + exchange.getExchangeId());
}
 
Example #18
Source File: IntegrationActivityTrackingPolicy.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
public void onExchangeDone(Route route, Exchange exchange) {
    if (tracker == null) {
        return;
    }

    tracker.finishTracking(exchange);
}
 
Example #19
Source File: AsyncProcessTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #20
Source File: CamelVariableTransferTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
  List<Route> routes = camelContext.getRoutes();
  for (Route r: routes) {
    camelContext.stopRoute(r.getId());
    camelContext.removeRoute(r.getId());
  }
}
 
Example #21
Source File: CamelVariableBodyMapTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
  List<Route> routes = camelContext.getRoutes();
  for (Route r : routes) {
    camelContext.stopRoute(r.getId());
    camelContext.removeRoute(r.getId());
  }
}
 
Example #22
Source File: EmptyProcessTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
  List<Route> routes = camelContext.getRoutes();
  for (Route r : routes) {
    camelContext.stopRoute(r.getId());
    camelContext.removeRoute(r.getId());
  }
}
 
Example #23
Source File: AsyncProcessTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
  List<Route> routes = camelContext.getRoutes();
  for (Route r : routes) {
    camelContext.stopRoute(r.getId());
    camelContext.removeRoute(r.getId());
  }
}
 
Example #24
Source File: CamelExceptionTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
  List<Route> routes = camelContext.getRoutes();
  for (Route r : routes) {
    camelContext.stopRoute(r.getId());
    camelContext.removeRoute(r.getId());
  }
}
 
Example #25
Source File: CdiCamelVariableBodyTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #26
Source File: CdiCamelVariableBodyMapTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@After
public void tearDown() throws Exception {
    List<Route> routes = camelContext.getRoutes();
    for (Route r : routes) {
        camelContext.stopRoute(r.getId());
        camelContext.removeRoute(r.getId());
    }
}
 
Example #27
Source File: AsyncPingTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
  List<Route> routes = camelContext.getRoutes();
  for (Route r : routes) {
    camelContext.stopRoute(r.getId());
    camelContext.removeRoute(r.getId());
  }
}
 
Example #28
Source File: ParallelProcessTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
  List<Route> routes = camelContext.getRoutes();
  for (Route r : routes) {
    camelContext.stopRoute(r.getId());
    camelContext.removeRoute(r.getId());
  }
}
 
Example #29
Source File: SimpleProcessTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
  List<Route> routes = camelContext.getRoutes();
  for (Route r : routes) {
    camelContext.stopRoute(r.getId());
    camelContext.removeRoute(r.getId());
  }
}
 
Example #30
Source File: CamelVariableBodyTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void tearDown() throws Exception {
  List<Route> routes = camelContext.getRoutes();
  for (Route r : routes) {
    camelContext.stopRoute(r.getId());
    camelContext.removeRoute(r.getId());
  }
}