整数属性验证错误(camel)

时间:2015-01-09 11:22:12

标签: apache-camel

我正在使用Blueprint Camel(v 2.13.2)中的OSGi配置属性,一切正常,直到我尝试使用整数属性属性:timePeriodMillis in tag。

这段代码很好用:

<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>

当我的属性timePeriodMillis:

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

我收到两个验证错误:

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'.

当我将其更改为(无引用)时:

<throttle timePeriodMillis={{timePM}}>  

我再次遇到验证错误:

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

有什么想法吗?感谢

1 个答案:

答案 0 :(得分:3)

有关使用属性占位符的信息,请参阅Camel文档。 在[1]中的XML DSL 中使用属性占位符的任何类型的属性解释了如何对任何类型的属性使用占位符。这允许将字符串类型{{foo}}用于否则需要数字的类型。

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