Search in sources :

Example 1 with HystrixDefinition

use of org.apache.camel.model.HystrixDefinition in project camel by apache.

the class HystrixHierarchicalConfigTest method testContextConfiguration.

@Test
public void testContextConfiguration() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    HystrixConfigurationDefinition def = new HystrixConfigurationDefinition();
    def.setGroupKey("global-group-key");
    def.setThreadPoolKey("global-thread-key");
    def.setCorePoolSize(10);
    HystrixConfigurationDefinition ref = new HystrixConfigurationDefinition();
    ref.setGroupKey("ref-group-key");
    ref.setCorePoolSize(5);
    context.setHystrixConfiguration(def);
    context.addHystrixConfiguration("ref-hystrix", ref);
    final HystrixProcessorFactory factory = new HystrixProcessorFactory();
    final HystrixConfigurationDefinition config = factory.buildHystrixConfiguration(context, new HystrixDefinition().hystrixConfiguration("ref-hystrix").hystrixConfiguration().groupKey("local-conf-group-key").requestLogEnabled(false).end());
    Assert.assertEquals("local-conf-group-key", config.getGroupKey());
    Assert.assertEquals("global-thread-key", config.getThreadPoolKey());
    Assert.assertEquals(new Integer(5), config.getCorePoolSize());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) HystrixConfigurationDefinition(org.apache.camel.model.HystrixConfigurationDefinition) HystrixDefinition(org.apache.camel.model.HystrixDefinition) Test(org.junit.Test)

Example 2 with HystrixDefinition

use of org.apache.camel.model.HystrixDefinition in project camel by apache.

the class HystrixHierarchicalConfigurationTest method testConfiguration.

@Test
public void testConfiguration() throws Exception {
    RouteDefinition routeDefinition = camelContext.getRouteDefinition("hystrix-route");
    HystrixDefinition hystrixDefinition = findHystrixDefinition(routeDefinition);
    Assert.assertNotNull(hystrixDefinition);
    HystrixProcessorFactory factory = new HystrixProcessorFactory();
    HystrixConfigurationDefinition config = factory.buildHystrixConfiguration(camelContext, hystrixDefinition);
    Assert.assertEquals("local-conf-group-key", config.getGroupKey());
    Assert.assertEquals("global-thread-key", config.getThreadPoolKey());
    Assert.assertEquals(new Integer(5), config.getCorePoolSize());
}
Also used : RouteDefinition(org.apache.camel.model.RouteDefinition) HystrixDefinition(org.apache.camel.model.HystrixDefinition) HystrixConfigurationDefinition(org.apache.camel.model.HystrixConfigurationDefinition) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with HystrixDefinition

use of org.apache.camel.model.HystrixDefinition in project camel by apache.

the class HystrixHierarchicalConfigTest method testRegistryConfiguration.

@Test
public void testRegistryConfiguration() throws Exception {
    final SimpleRegistry registry = new SimpleRegistry();
    final CamelContext context = new DefaultCamelContext(registry);
    HystrixConfigurationDefinition def = new HystrixConfigurationDefinition();
    def.setGroupKey("global-group-key");
    def.setThreadPoolKey("global-thread-key");
    def.setCorePoolSize(10);
    HystrixConfigurationDefinition ref = new HystrixConfigurationDefinition();
    ref.setGroupKey("ref-group-key");
    ref.setCorePoolSize(5);
    registry.put(HystrixConstants.DEFAULT_HYSTRIX_CONFIGURATION_ID, def);
    registry.put("ref-hystrix", ref);
    final HystrixProcessorFactory factory = new HystrixProcessorFactory();
    final HystrixConfigurationDefinition config = factory.buildHystrixConfiguration(context, new HystrixDefinition().hystrixConfiguration("ref-hystrix").hystrixConfiguration().groupKey("local-conf-group-key").requestLogEnabled(false).end());
    Assert.assertEquals("local-conf-group-key", config.getGroupKey());
    Assert.assertEquals("global-thread-key", config.getThreadPoolKey());
    Assert.assertEquals(new Integer(5), config.getCorePoolSize());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) HystrixConfigurationDefinition(org.apache.camel.model.HystrixConfigurationDefinition) HystrixDefinition(org.apache.camel.model.HystrixDefinition) Test(org.junit.Test)

Example 4 with HystrixDefinition

use of org.apache.camel.model.HystrixDefinition in project camel by apache.

the class HystrixHierarchicalConfigTest method testMixedConfiguration.

@Test
public void testMixedConfiguration() throws Exception {
    final SimpleRegistry registry = new SimpleRegistry();
    final CamelContext context = new DefaultCamelContext(registry);
    HystrixConfigurationDefinition def = new HystrixConfigurationDefinition();
    def.setGroupKey("global-group-key");
    def.setThreadPoolKey("global-thread-key");
    def.setCorePoolSize(10);
    HystrixConfigurationDefinition ref = new HystrixConfigurationDefinition();
    ref.setGroupKey("ref-group-key");
    ref.setCorePoolSize(5);
    // this should be ignored
    HystrixConfigurationDefinition defReg = new HystrixConfigurationDefinition();
    defReg.setGroupKey("global-reg-group-key");
    defReg.setThreadPoolKey("global-reg-thread-key");
    defReg.setCorePoolSize(20);
    context.setHystrixConfiguration(def);
    registry.put(HystrixConstants.DEFAULT_HYSTRIX_CONFIGURATION_ID, defReg);
    registry.put("ref-hystrix", ref);
    final HystrixProcessorFactory factory = new HystrixProcessorFactory();
    final HystrixConfigurationDefinition config = factory.buildHystrixConfiguration(context, new HystrixDefinition().hystrixConfiguration("ref-hystrix").hystrixConfiguration().groupKey("local-conf-group-key").requestLogEnabled(false).end());
    Assert.assertEquals("local-conf-group-key", config.getGroupKey());
    Assert.assertEquals("global-thread-key", config.getThreadPoolKey());
    Assert.assertEquals(new Integer(5), config.getCorePoolSize());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) HystrixConfigurationDefinition(org.apache.camel.model.HystrixConfigurationDefinition) HystrixDefinition(org.apache.camel.model.HystrixDefinition) Test(org.junit.Test)

Example 5 with HystrixDefinition

use of org.apache.camel.model.HystrixDefinition 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());
}
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)

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