问题
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
回答1:
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
来源:https://stackoverflow.com/questions/27859466/validation-error-with-integer-property-camel