Search in sources :

Example 6 with HystrixDefinition

use of org.apache.camel.model.HystrixDefinition 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());
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) RouteDefinition(org.apache.camel.model.RouteDefinition) HystrixConfigurationDefinition(org.apache.camel.model.HystrixConfigurationDefinition) HystrixDefinition(org.apache.camel.model.HystrixDefinition) Test(org.junit.Test)

Example 7 with HystrixDefinition

use of org.apache.camel.model.HystrixDefinition 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();
}
Also used : RouteDefinition(org.apache.camel.model.RouteDefinition) HystrixDefinition(org.apache.camel.model.HystrixDefinition) HystrixConfigurationDefinition(org.apache.camel.model.HystrixConfigurationDefinition) Test(org.junit.Test)

Aggregations

HystrixConfigurationDefinition (org.apache.camel.model.HystrixConfigurationDefinition)7 HystrixDefinition (org.apache.camel.model.HystrixDefinition)7 Test (org.junit.Test)7 RouteDefinition (org.apache.camel.model.RouteDefinition)4 CamelContext (org.apache.camel.CamelContext)3 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)3 RouteBuilder (org.apache.camel.builder.RouteBuilder)2 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1