我试图根据属性文件中的布尔值有条件地在XML DSL中启动路由。但它有点不起作用。我不确定这是不是正确的做法。任何帮助表示赞赏,谢谢:)
这是我的blueprint.xml
<bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
<property name="location" value="classpath:property.properties"/>
</bean>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route autoStartup="${isTrue}">
<from uri="pipe:prs:P" />
<choice>
<when>
<simple>${headers.headerName} == 'DR91'</simple>
<process ref="reqType"></process>
<to uri="direct-vm:pipeRequestDR91" />
</when>
<when>
<simple>${headers.headerName} == 'DR93'</simple>
<process ref="reqType"></process>
<to uri="direct-vm:pipeRequestDR93" />
</when>
</choice>
</route>
这是我的属性文件 - property.properties
isTrue=true
我得到的错误说:
org.apache.camel.RuntimeCamelException:
org.apache.camel.FailedToCreateRouteException: Failed to create route
route1: Route(route1)[[From[pipe:prs:P]] -> [Choice[[When[simple{${h...
because of Error parsing [${isTrue}] as a Boolean.
答案 0 :(得分:3)
您应该使用Camel的属性占位符语法{{xxx}}
,例如
<route autoStartup="{{isTrue}}">
答案 1 :(得分:0)