Java源码示例:org.apache.camel.Route
示例1
@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();
}
示例2
@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);
}
}
示例3
@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);
}
}
示例4
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例5
@Test
public void testConfiguration() throws Exception {
RouteDefinition routeDefinition = camelContext.getExtension(Model.class).getRouteDefinition("hystrix-route");
CircuitBreakerDefinition hystrixDefinition = findCircuitBreaker(routeDefinition);
Assert.assertNotNull(hystrixDefinition);
Route rc = new DefaultRoute(camelContext, null, null, null, null);
HystrixReifier reifier = new HystrixReifier(rc, hystrixDefinition);
HystrixConfigurationDefinition config = reifier.buildHystrixConfiguration();
Assert.assertEquals("local-conf-group-key", config.getGroupKey());
Assert.assertEquals("global-thread-key", config.getThreadPoolKey());
Assert.assertEquals("5", config.getCorePoolSize());
}
示例6
protected DefaultServiceCallProcessor findServiceCallProcessor(CamelContext context) {
Route route = context.getRoute("scall");
Assert.assertNotNull("ServiceCall Route should be present", route);
return findServiceCallProcessor(route.navigate())
.orElseThrow(() -> new IllegalStateException("Unable to find a ServiceCallProcessor"));
}
示例7
public RouteInfo(Route route) {
this.id = route.getId();
this.description = route.getDescription();
this.uptime = route.getUptime();
this.uptimeMillis = route.getUptimeMillis();
if (route instanceof StatefulService) {
this.status = ((StatefulService) route).getStatus().name();
} else {
this.status = null;
}
}
示例8
public RouteDetailsInfo(final CamelContext camelContext, final Route route) {
super(route);
ManagedCamelContext mc = camelContext.getExtension(ManagedCamelContext.class);
if (mc != null) {
this.routeDetails = new RouteDetails(mc.getManagedRoute(route.getId()));
}
}
示例9
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例10
@Test
public void shouldDetectRoutes() {
// When
Route route = camelContext.getRoute(TestConfig.ROUTE_ID);
// Then
assertNotNull(route);
}
示例11
@Test
public void shouldDetectRoutes() {
// When
Route route = camelContext.getRoute("foo");
// Then
assertNotNull(route);
// When
route = camelContext.getRoute("bar");
// Then
assertNotNull(route);
}
示例12
@Override
public void onInit(Route route) {
super.onInit(route);
route.setAutoStartup(false);
if (route.getEndpoint() instanceof WebhookEndpoint) {
WebhookEndpoint webhook = (WebhookEndpoint)route.getEndpoint();
if (webhook.getConfiguration() != null && webhook.getConfiguration().isWebhookAutoRegister()) {
throw new IllegalStateException(
"Webhook auto-register is enabled on endpoint " + webhook + ": it must be disabled when the WebhookRoutePolicy is active");
}
executeWebhookAction(webhook.getEndpoint());
}
}
示例13
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例14
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例15
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例16
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例17
@After
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例18
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例19
@After
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例20
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例21
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例22
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例23
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例24
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例25
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例26
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例27
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例28
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例29
@After
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}
示例30
@After
public void tearDown() throws Exception {
List<Route> routes = camelContext.getRoutes();
for (Route r : routes) {
camelContext.stopRoute(r.getId());
camelContext.removeRoute(r.getId());
}
}