org.apache.camel.model.HystrixConfigurationDefinition Java Examples

The following examples show how to use org.apache.camel.model.HystrixConfigurationDefinition. 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: HystrixProcessor.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        BuildProducer<NativeImageSystemPropertyBuildItem> systemProperty) {

    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true,
            HystrixConfigurationCommon.class,
            HystrixConfigurationDefinition.class,
            CircuitBreakerDefinition.class,
            OnFallbackDefinition.class));

    // Force RxJava to not use Unsafe API
    systemProperty.produce(new NativeImageSystemPropertyBuildItem("rx.unsafe-disable", "true"));
}
 
Example #2
Source File: HystrixAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Bean(name = HystrixConstants.DEFAULT_HYSTRIX_CONFIGURATION_ID)
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(name = HystrixConstants.DEFAULT_HYSTRIX_CONFIGURATION_ID)
public HystrixConfigurationDefinition defaultHystrixConfigurationDefinition() throws Exception {
    Map<String, Object> properties = new HashMap<>();

    IntrospectionSupport.getProperties(config, properties, null, false);
    HystrixConfigurationDefinition definition = new HystrixConfigurationDefinition();
    IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), definition, properties);

    return definition;
}
 
Example #3
Source File: HystrixAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void postConstruct() {
    if (beanFactory == null) {
        return;
    }

    Map<String, Object> properties = new HashMap<>();

    for (Map.Entry<String, HystrixConfigurationDefinitionCommon> entry : config.getConfigurations().entrySet()) {

        // clear the properties map for reuse
        properties.clear();

        // extract properties
        IntrospectionSupport.getProperties(entry.getValue(), properties, null, false);

        try {
            HystrixConfigurationDefinition definition = new HystrixConfigurationDefinition();
            IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), definition, properties);

            // Registry the definition
            beanFactory.registerSingleton(entry.getKey(), definition);

        } catch (Exception e) {
            throw new BeanCreationException(entry.getKey(), e);
        }
    }
}
 
Example #4
Source File: HystrixMultiConfigurationTest.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void testBeans() throws Exception {
    Map<String, HystrixConfigurationDefinition> beans = context.getBeansOfType(HystrixConfigurationDefinition.class);

    Assert.assertEquals(4, beans.size());
    Assert.assertEquals("global-group", beans.get(HystrixConstants.DEFAULT_HYSTRIX_CONFIGURATION_ID).getGroupKey());
    Assert.assertEquals("bean-group", beans.get("bean-conf").getGroupKey());
    Assert.assertEquals("conf-1-group", beans.get("conf-1").getGroupKey());
    Assert.assertEquals("conf-2-group", beans.get("conf-2").getGroupKey());
}
 
Example #5
Source File: HystrixHierarchicalConfigurationTest.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #6
Source File: HystrixMultiConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "bean-conf")
public HystrixConfigurationDefinition hystrixBeanConfiguration() {
    return new HystrixConfigurationDefinition()
        .groupKey("bean-group");
}
 
Example #7
Source File: HystrixHierarchicalConfiguration.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Bean(name = "ref-hystrix")
public HystrixConfigurationDefinition hystrixConfiguration() {
    return new HystrixConfigurationDefinition()
        .groupKey("ref-group-key")
        .corePoolSize(5);
}
 
Example #8
Source File: CircuitBreakerStepParser.java    From camel-k-runtime with Apache License 2.0 4 votes vote down vote up
public HystrixConfigurationDefinition getHystrixConfiguration() {
    return delegate.getHystrixConfiguration();
}
 
Example #9
Source File: CircuitBreakerStepParser.java    From camel-k-runtime with Apache License 2.0 4 votes vote down vote up
public void setHystrixConfiguration(HystrixConfigurationDefinition hystrixConfiguration) {
    delegate.setHystrixConfiguration(hystrixConfiguration);
}