2

I'am using OSGi Configuration Properties in Blueprint Camel (v 2.13.2) and everything was fine until I tried to properties a integer property : timePeriodMillis in tag.

This code works nice :

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
         http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
         http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">


    <cm:property-placeholder persistent-id="myprops"/>

    <camelContext  xmlns="http://camel.apache.org/schema/blueprint">

        <route id="rt" trace="false" autoStartup="false">
            <from uri="amq://{{myQueue}}"/>
            <throttle timePeriodMillis="5">
                <constant>{{maxRPP}}</constant>
                <to uri="direct:mock" />
            </throttle>
        </route>    
    </camelContext>
</blueprint>

When I properties timePeriodMillis :

<throttle timePeriodMillis="{{timePM}}">

I got two validation errors :

cvc-attribute.3: The value '{{timePM}}' of attribute 'timePeriodMillis' on element 'throttle' is not valid with respect to its type, 'long'.
cvc-datatype-valid.1.2.1: '{{timePM}}' is not a valid value for 'integer'.

When I change it to (no quote) :

<throttle timePeriodMillis={{timePM}}>  

I got again a validation error :

Open quote is expected for attribute "timePeriodMillis" associated with an  element type  "throttle".

Any idea ? Thanks

Bertrand
  • 109
  • 2
  • 10

1 Answers1

4

See the Camel documentation for using property placeholders. The section Using property placeholders for any kind of attribute in the XML DSL at [1] explains how to use placeholders for any kind of attribute. This allows to use string types {{foo}} for types that otherwise would require a number.

[1] - http://camel.apache.org/using-propertyplaceholder.html

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
  • Thanks it works nice. I didn't catch the real sense of this section cause the stop property is a boolean... – Bertrand Jan 09 '15 at 14:50
  • 1
    I'm having the same issue and while I looked at the link provided, it's unclear to me what to do to get it to "work". – Joe Dec 19 '16 at 19:28
  • 1
    Please check a detailed answer here --> https://stackoverflow.com/a/45125953/1521346 – Bhuvan Sep 26 '18 at 08:03