use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class HystrixRouteConfigMaximumSizeTest method testGroupKeyAndThreadPoolKeyConfigFlagsDoNotScrapHystrixConfiguration.
@Test
public void testGroupKeyAndThreadPoolKeyConfigFlagsDoNotScrapHystrixConfiguration() throws Exception {
// dummy route
RouteBuilder rb = new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:foo").hystrix().hystrixConfiguration().groupKey("test1").metricsHealthSnapshotIntervalInMilliseconds(99999).end().groupKey("test2").to("log:hello").end();
}
};
rb.configure();
RouteDefinition route = rb.getRouteCollection().getRoutes().get(0);
assertEquals(HystrixDefinition.class, route.getOutputs().get(0).getClass());
HystrixConfigurationDefinition config = ((HystrixDefinition) route.getOutputs().get(0)).getHystrixConfiguration();
assertEquals("test2", config.getGroupKey());
assertEquals(99999, config.getMetricsHealthSnapshotIntervalInMilliseconds().intValue());
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class HystrixRouteConfigTest method testGroupKeyAndThreadPoolKeyConfigFlagsDoNotScrapHystrixConfiguration.
@Test
public void testGroupKeyAndThreadPoolKeyConfigFlagsDoNotScrapHystrixConfiguration() throws Exception {
// dummy route
RouteBuilder rb = new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:foo").hystrix().hystrixConfiguration().groupKey("test1").metricsHealthSnapshotIntervalInMilliseconds(99999).end().groupKey("test2").to("log:hello").end();
}
};
rb.configure();
RouteDefinition route = rb.getRouteCollection().getRoutes().get(0);
assertEquals(HystrixDefinition.class, route.getOutputs().get(0).getClass());
HystrixConfigurationDefinition config = ((HystrixDefinition) route.getOutputs().get(0)).getHystrixConfiguration();
assertEquals("test2", config.getGroupKey());
assertEquals(99999, config.getMetricsHealthSnapshotIntervalInMilliseconds().intValue());
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class SpringHystrixRouteHierarchicalConfigTest method testHystrix.
@Test
public void testHystrix() throws Exception {
RouteDefinition routeDefinition = context.getRouteDefinition("hystrix-route");
HystrixDefinition hystrixDefinition = findHystrixDefinition(routeDefinition);
Assert.assertNotNull(hystrixDefinition);
HystrixProcessorFactory factory = new HystrixProcessorFactory();
HystrixConfigurationDefinition config = factory.buildHystrixConfiguration(context, hystrixDefinition);
Assert.assertEquals("local-conf-group-key", config.getGroupKey());
Assert.assertEquals("global-thread-key", config.getThreadPoolKey());
Assert.assertEquals(new Integer(5), config.getCorePoolSize());
getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class DefaultManagementLifecycleStrategy method onRouteContextCreate.
public void onRouteContextCreate(RouteContext routeContext) {
if (!initialized) {
return;
}
// Create a map (ProcessorType -> PerformanceCounter)
// to be passed to InstrumentationInterceptStrategy.
Map<ProcessorDefinition<?>, PerformanceCounter> registeredCounters = new HashMap<ProcessorDefinition<?>, PerformanceCounter>();
// Each processor in a route will have its own performance counter.
// These performance counter will be embedded to InstrumentationProcessor
// and wrap the appropriate processor by InstrumentationInterceptStrategy.
RouteDefinition route = routeContext.getRoute();
// register performance counters for all processors and its children
for (ProcessorDefinition<?> processor : route.getOutputs()) {
registerPerformanceCounters(routeContext, processor, registeredCounters);
}
// set this managed intercept strategy that executes the JMX instrumentation for performance metrics
// so our registered counters can be used for fine grained performance instrumentation
routeContext.setManagedInterceptStrategy(new InstrumentationInterceptStrategy(registeredCounters, wrappedProcessors));
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class ValidateIdTest method testValidateId.
public void testValidateId() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
RouteDefinition route = context.getRouteDefinition("myRoute");
assertNotNull(route);
// mock:result should be the only with the result as id
assertTrue(route.getOutputs().get(0).getId().equals("myValidate"));
assertFalse(route.getOutputs().get(1).getId().equals("result"));
assertTrue(route.getOutputs().get(2).getId().equals("result"));
assertTrue(route.getOutputs().get(3).getId().equals("after"));
}
Aggregations