Search in sources :

Example 1 with DefaultFluentProducerTemplate

use of org.apache.camel.builder.DefaultFluentProducerTemplate in project camel by apache.

the class AbstractCamelFluentProducerTemplateFactoryBean method getObject.

public FluentProducerTemplate getObject() throws Exception {
    CamelContext context = getCamelContext();
    if (defaultEndpoint != null) {
        Endpoint endpoint = context.getEndpoint(defaultEndpoint);
        if (endpoint == null) {
            throw new IllegalArgumentException("No endpoint found for URI: " + defaultEndpoint);
        } else {
            template = new DefaultFluentProducerTemplate(context);
            template.setDefaultEndpoint(endpoint);
        }
    } else {
        template = new DefaultFluentProducerTemplate(context);
    }
    // set custom cache size if provided
    if (maximumCacheSize != null) {
        template.setMaximumCacheSize(maximumCacheSize);
    }
    // must start it so its ready to use
    ServiceHelper.startService(template);
    return template;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultFluentProducerTemplate(org.apache.camel.builder.DefaultFluentProducerTemplate) Endpoint(org.apache.camel.Endpoint)

Example 2 with DefaultFluentProducerTemplate

use of org.apache.camel.builder.DefaultFluentProducerTemplate in project camel by apache.

the class DefaultCamelContext method createFluentProducerTemplate.

public FluentProducerTemplate createFluentProducerTemplate(int maximumCacheSize) {
    DefaultFluentProducerTemplate answer = new DefaultFluentProducerTemplate(this);
    answer.setMaximumCacheSize(maximumCacheSize);
    // start it so its ready to use
    try {
        startService(answer);
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
    return answer;
}
Also used : DefaultFluentProducerTemplate(org.apache.camel.builder.DefaultFluentProducerTemplate) RuntimeCamelException(org.apache.camel.RuntimeCamelException) MalformedObjectNameException(javax.management.MalformedObjectNameException) VetoCamelContextStartException(org.apache.camel.VetoCamelContextStartException) IOException(java.io.IOException) LoadPropertiesException(org.apache.camel.util.LoadPropertiesException) NoSuchEndpointException(org.apache.camel.NoSuchEndpointException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) NoFactoryAvailableException(org.apache.camel.NoFactoryAvailableException) FailedToStartRouteException(org.apache.camel.FailedToStartRouteException)

Example 3 with DefaultFluentProducerTemplate

use of org.apache.camel.builder.DefaultFluentProducerTemplate in project camel by apache.

the class CamelPostProcessorHelper method createInjectionFluentProducerTemplate.

/**
     * Factory method to create a
     * {@link org.apache.camel.FluentProducerTemplate} to be injected into a
     * POJO
     */
protected FluentProducerTemplate createInjectionFluentProducerTemplate(String endpointUri, String endpointRef, String endpointProperty, String injectionPointName, Object bean) {
    // endpoint is optional for this injection point
    Endpoint endpoint = getEndpointInjection(bean, endpointUri, endpointRef, endpointProperty, injectionPointName, false);
    CamelContext context = endpoint != null ? endpoint.getCamelContext() : getCamelContext();
    FluentProducerTemplate answer = new DefaultFluentProducerTemplate(context);
    answer.setDefaultEndpoint(endpoint);
    // start the template so its ready to use
    try {
        // no need to defer the template as it can adjust to the endpoint at runtime
        startService(answer, context, bean, null);
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
    return answer;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultFluentProducerTemplate(org.apache.camel.builder.DefaultFluentProducerTemplate) Endpoint(org.apache.camel.Endpoint) DefaultFluentProducerTemplate(org.apache.camel.builder.DefaultFluentProducerTemplate) FluentProducerTemplate(org.apache.camel.FluentProducerTemplate) NoSuchBeanException(org.apache.camel.NoSuchBeanException) ProxyInstantiationException(org.apache.camel.ProxyInstantiationException)

Aggregations

DefaultFluentProducerTemplate (org.apache.camel.builder.DefaultFluentProducerTemplate)3 CamelContext (org.apache.camel.CamelContext)2 Endpoint (org.apache.camel.Endpoint)2 IOException (java.io.IOException)1 MalformedObjectNameException (javax.management.MalformedObjectNameException)1 FailedToStartRouteException (org.apache.camel.FailedToStartRouteException)1 FluentProducerTemplate (org.apache.camel.FluentProducerTemplate)1 NoFactoryAvailableException (org.apache.camel.NoFactoryAvailableException)1 NoSuchBeanException (org.apache.camel.NoSuchBeanException)1 NoSuchEndpointException (org.apache.camel.NoSuchEndpointException)1 ProxyInstantiationException (org.apache.camel.ProxyInstantiationException)1 ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)1 RuntimeCamelException (org.apache.camel.RuntimeCamelException)1 VetoCamelContextStartException (org.apache.camel.VetoCamelContextStartException)1 LoadPropertiesException (org.apache.camel.util.LoadPropertiesException)1