Camel
  1. Camel
  2. CAMEL-5007

PropertiesComponent on errorHandler properties

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.9.0
    • Fix Version/s: 2.9.2, 2.10.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      PropertiesComponent should apply on errorHandler and redeliveryPolicy properties definition in the camel context.

        Activity

        Hide
        Willem Jiang added a comment -

        Hi Alessio,

        I just take a quick look at the code (ErrorHandlerDefinitionParser). It is hard to add the support of resolving the value of PropertiesComponent, as the ErrorHandlder is not bund to the camel context which provides a way to resolve the value of properties.

        To address that, we may need to do refactor on the camel-core to delay the creation of the ErrorHandler or find a more generic way resolve the value of PropertiesComponent.

        For now, we could workaround it by using the property resolve of spring.

        Willem

        Show
        Willem Jiang added a comment - Hi Alessio, I just take a quick look at the code (ErrorHandlerDefinitionParser). It is hard to add the support of resolving the value of PropertiesComponent, as the ErrorHandlder is not bund to the camel context which provides a way to resolve the value of properties. To address that, we may need to do refactor on the camel-core to delay the creation of the ErrorHandler or find a more generic way resolve the value of PropertiesComponent. For now, we could workaround it by using the property resolve of spring. Willem
        Hide
        Claus Ibsen added a comment -

        This should already be supported. Can you provide a use-case that does not?

        Show
        Claus Ibsen added a comment - This should already be supported. Can you provide a use-case that does not?
        Hide
        Alessio Giannetti added a comment - - edited

        Like said here http://camel.apache.org/properties.html
        "Camel now provides a new PropertiesComponent in camel-core which allows you to use property placeholders when defining Camel Endpoint URIs."
        So it works just with endpoint definition.
        I would have used something like:

        <propertyPlaceholder id="properties" location="classpath:bonus-tracker-context.properties" prefixToken="#[" suffixToken="]"/>

        <endpoint id="getBulkBonusMessagesTimer"
        uri="timer://getBulkBonusMessagesTimer?fixedRate=true&period=#[bulkBonusMessagesTimerPeriod]"/>

        <errorHandler id="myErrorHandler" type="DefaultErrorHandler">
        <redeliveryPolicy maximumRedeliveries="#[mrp]"
        retryAttemptedLogLevel="#[rall]"
        redeliverDelay="#[rd]"/>
        </errorHandler>

        But the propertiesComponent works only with the uri definition.

        So i just defined

        <bean id="errorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder">
        <property name="deadLetterUri" value="seda:deadLetterManager"/>
        <property name="useOriginalMessage" value="true"/>
        <property name="redeliveryPolicy" ref="redeliveryPolicy"/>
        </bean>

        <bean id="redeliveryPolicy" class="org.apache.camel.processor.RedeliveryPolicy">
        <property name="maximumRedeliveries" value="$

        {errorHandler.maximumRedeliveries}

        "/>
        <property name="redeliverDelay" value="$

        {errorHandler.redeliveryDelay}

        "/>
        <property name="retryAttemptedLogLevel" value="$

        {errorHandler.retryAttemptedLogLevel}

        "/>
        </bean>

        in spring and used it in the camel context.

        Show
        Alessio Giannetti added a comment - - edited Like said here http://camel.apache.org/properties.html "Camel now provides a new PropertiesComponent in camel-core which allows you to use property placeholders when defining Camel Endpoint URIs." So it works just with endpoint definition. I would have used something like: <propertyPlaceholder id="properties" location="classpath:bonus-tracker-context.properties" prefixToken="# [" suffixToken="] "/> <endpoint id="getBulkBonusMessagesTimer" uri="timer://getBulkBonusMessagesTimer?fixedRate=true&period=# [bulkBonusMessagesTimerPeriod] "/> <errorHandler id="myErrorHandler" type="DefaultErrorHandler"> <redeliveryPolicy maximumRedeliveries="# [mrp] " retryAttemptedLogLevel="# [rall] " redeliverDelay="# [rd] "/> </errorHandler> But the propertiesComponent works only with the uri definition. So i just defined <bean id="errorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder"> <property name="deadLetterUri" value="seda:deadLetterManager"/> <property name="useOriginalMessage" value="true"/> <property name="redeliveryPolicy" ref="redeliveryPolicy"/> </bean> <bean id="redeliveryPolicy" class="org.apache.camel.processor.RedeliveryPolicy"> <property name="maximumRedeliveries" value="$ {errorHandler.maximumRedeliveries} "/> <property name="redeliverDelay" value="$ {errorHandler.redeliveryDelay} "/> <property name="retryAttemptedLogLevel" value="$ {errorHandler.retryAttemptedLogLevel} "/> </bean> in spring and used it in the camel context.
        Hide
        Claus Ibsen added a comment -

        Thanks I have reproduced the issue. Its when you embed a <redeliveryPolicy> inside the <errorHandler>. This requires a bit more than Spring can handle, so we need to adjust the error handler parser a bit in camel-spring, to fix this.

        Show
        Claus Ibsen added a comment - Thanks I have reproduced the issue. Its when you embed a <redeliveryPolicy> inside the <errorHandler>. This requires a bit more than Spring can handle, so we need to adjust the error handler parser a bit in camel-spring, to fix this.
        Hide
        Claus Ibsen added a comment -

        We should also check the Blueprint XML DSL as well to see if there is a problem as well.

        Show
        Claus Ibsen added a comment - We should also check the Blueprint XML DSL as well to see if there is a problem as well.
        Hide
        Claus Ibsen added a comment -

        I got a pending fix for camel-spring. Will have to do a similar fix for camel-blueprint.

        Show
        Claus Ibsen added a comment - I got a pending fix for camel-spring. Will have to do a similar fix for camel-blueprint.
        Hide
        Claus Ibsen added a comment -

        Now works for both Spring and Blueprint XML DSLs

        Show
        Claus Ibsen added a comment - Now works for both Spring and Blueprint XML DSLs

          People

          • Assignee:
            Claus Ibsen
            Reporter:
            Alessio Giannetti
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development