org.apache.camel.model.cloud.ServiceCallConfigurationDefinition Java Examples

The following examples show how to use org.apache.camel.model.cloud.ServiceCallConfigurationDefinition. 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: MyStaticRouteGlobal.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
public void configure() throws Exception {
    // create a Service Call EIP configuration
    ServiceCallConfigurationDefinition global = new ServiceCallConfigurationDefinition();
    // use the http4 component
    global.component("http4")
        // add the static list of servers
        .staticServiceDiscovery()
            // the syntax is name@hostname:port
            // and you can separate multiple servers by comma
            .servers("hello-service@localhost:8081,hello-service@localhost:8082");

    // set as global configuration on CamelContext
    getContext().setServiceCallConfiguration(global);

    // Camel route that calls the service
    from("timer:trigger?period=2000")
        // `hello-service` = name of service
        // `/camel/hello` is used in uri templating which
        // means this is used in the context-path of the actual http4 uri
        .serviceCall("hello-service/camel/hello")
        .log("Response ${body}");
}
 
Example #2
Source File: BaseModel.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public ServiceCallConfigurationDefinition getServiceCallConfiguration(String serviceName) {
    if (serviceName == null) {
        serviceName = "";
    }

    return serviceCallConfigurations.get(serviceName);
}
 
Example #3
Source File: BaseModel.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public void setServiceCallConfigurations(List<ServiceCallConfigurationDefinition> configurations) {
    if (configurations != null) {
        for (ServiceCallConfigurationDefinition configuration : configurations) {
            serviceCallConfigurations.put(configuration.getId(), configuration);
        }
    }
}
 
Example #4
Source File: CamelCloudServiceCallConfigurationAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = ServiceCallDefinitionConstants.DEFAULT_SERVICE_CALL_CONFIG_ID)
@ConditionalOnMissingBean(name = ServiceCallDefinitionConstants.DEFAULT_SERVICE_CALL_CONFIG_ID)
public ServiceCallConfigurationDefinition serviceCallConfiguration() throws Exception {
    final ServiceCallConfigurationDefinition definition = new ServiceCallConfigurationDefinition();
    final CamelCloudConfigurationProperties.ServiceCall serviceCall = configurationProperties.getServiceCall();

    ObjectHelper.ifNotEmpty(serviceCall.getComponent(), definition::setComponent);
    ObjectHelper.ifNotEmpty(serviceCall.getUri(), definition::setUri);
    ObjectHelper.ifNotEmpty(serviceCall.getServiceDiscovery(), definition::setServiceDiscoveryRef);
    ObjectHelper.ifNotEmpty(serviceCall.getServiceFilter(), definition::setServiceFilterRef);
    ObjectHelper.ifNotEmpty(serviceCall.getServiceChooser(), definition::setServiceChooserRef);
    ObjectHelper.ifNotEmpty(serviceCall.getLoadBalancer(), definition::setLoadBalancerRef);

    if (serviceCall.getLoadBalancer() == null && serviceCall.isDefaultLoadBalancer()) {
        definition.defaultLoadBalancer();
    }

    final String expression = serviceCall.getExpression();
    final String expressionLanguage = serviceCall.getExpressionLanguage();

    if (ObjectHelper.isNotEmpty(expression) && ObjectHelper.isNotEmpty(expressionLanguage)) {
        Language language = camelContext.resolveLanguage(expressionLanguage);
        if (language == null) {
            throw new IllegalArgumentException("Unable to resolve language: " + expressionLanguage);
        }

        definition.setExpression(language.createExpression(expression));
    }

    return definition;
}
 
Example #5
Source File: BaseModel.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void setServiceCallConfiguration(ServiceCallConfigurationDefinition configuration) {
    serviceCallConfigurations.put("", configuration);
}
 
Example #6
Source File: BaseModel.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void addServiceCallConfiguration(String serviceName, ServiceCallConfigurationDefinition configuration) {
    serviceCallConfigurations.put(serviceName, configuration);
}
 
Example #7
Source File: FastCamelContext.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public ServiceCallConfigurationDefinition getServiceCallConfiguration(String serviceName) {
    return model.getServiceCallConfiguration(serviceName);
}
 
Example #8
Source File: FastCamelContext.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void setServiceCallConfiguration(ServiceCallConfigurationDefinition configuration) {
    model.setServiceCallConfiguration(configuration);
}
 
Example #9
Source File: FastCamelContext.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void setServiceCallConfigurations(List<ServiceCallConfigurationDefinition> configurations) {
    model.setServiceCallConfigurations(configurations);
}
 
Example #10
Source File: FastCamelContext.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void addServiceCallConfiguration(String serviceName, ServiceCallConfigurationDefinition configuration) {
    model.addServiceCallConfiguration(serviceName, configuration);
}