Search in sources :

Example 1 with RedeliveryPolicyFactoryBean

use of org.apache.camel.cdi.xml.RedeliveryPolicyFactoryBean in project camel by apache.

the class XmlErrorHandlerFactoryBean method setProperties.

private void setProperties(DefaultErrorHandlerBuilder builder) throws Exception {
    if (nonNull(handler.getDeadLetterHandleNewException())) {
        builder.setDeadLetterHandleNewException(handler.getDeadLetterHandleNewException());
    }
    builder.setDeadLetterUri(handler.getDeadLetterUri());
    builder.setExecutorServiceRef(handler.getExecutorServiceRef());
    builder.setRetryWhileRef(handler.getRetryWhileRef());
    if (nonNull(handler.getUseOriginalMessage())) {
        builder.setUseOriginalMessage(handler.getUseOriginalMessage());
    }
    if (isNotEmpty(handler.getOnExceptionOccurredRef())) {
        Processor processor = getReferenceByName(manager, handler.getOnExceptionOccurredRef(), Processor.class).orElseThrow(() -> new UnsatisfiedResolutionException(format("No bean with name [%s] to satisfy attribute [%s]", handler.getOnPrepareFailureRef(), "onExceptionOccurredRef")));
        builder.setOnExceptionOccurred(processor);
    }
    if (isNotEmpty(handler.getOnPrepareFailureRef())) {
        Processor processor = getReferenceByName(manager, handler.getOnPrepareFailureRef(), Processor.class).orElseThrow(() -> new UnsatisfiedResolutionException(format("No bean with name [%s] to satisfy attribute [%s]", handler.getOnPrepareFailureRef(), "onPrepareFailureRef")));
        builder.setOnPrepareFailure(processor);
    }
    if (isNotEmpty(handler.getOnRedeliveryRef())) {
        Processor processor = getReferenceByName(manager, handler.getOnRedeliveryRef(), Processor.class).orElseThrow(() -> new UnsatisfiedResolutionException(format("No bean with name [%s] to satisfy attribute [%s]", handler.getOnPrepareFailureRef(), "onRedeliveryRef")));
        builder.setOnRedelivery(processor);
    }
    if (nonNull(handler.getRedeliveryPolicy())) {
        RedeliveryPolicyFactoryBean policy = handler.getRedeliveryPolicy();
        policy.setBeanManager(manager);
        builder.setRedeliveryPolicy(policy.getObject());
    }
    if (isNotEmpty(handler.getRedeliveryPolicyRef())) {
        RedeliveryPolicy policy = getReferenceByName(manager, handler.getRedeliveryPolicyRef(), RedeliveryPolicy.class).orElseThrow(() -> new UnsatisfiedResolutionException(format("No bean with name [%s] to satisfy attribute [%s]", handler.getRedeliveryPolicyRef(), "redeliveryPolicyRef")));
        builder.setRedeliveryPolicy(policy);
    }
}
Also used : Processor(org.apache.camel.Processor) RedeliveryPolicyFactoryBean(org.apache.camel.cdi.xml.RedeliveryPolicyFactoryBean) RedeliveryPolicy(org.apache.camel.processor.RedeliveryPolicy) UnsatisfiedResolutionException(javax.enterprise.inject.UnsatisfiedResolutionException)

Aggregations

UnsatisfiedResolutionException (javax.enterprise.inject.UnsatisfiedResolutionException)1 Processor (org.apache.camel.Processor)1 RedeliveryPolicyFactoryBean (org.apache.camel.cdi.xml.RedeliveryPolicyFactoryBean)1 RedeliveryPolicy (org.apache.camel.processor.RedeliveryPolicy)1