【发布时间】:2017-01-19 03:13:07
【问题描述】:
我正在使用 apache camel 在端点之间创建路由,通过在一个端口上运行在 Tomcat 上的一个 URI(API 网关),我正在映射到在不同域和端口上运行在 Tomcat 上的另一个 URI。
<bean id="hostnameVerifier" class="org.apache.http.conn.ssl.AllowAllHostnameVerifier" />
...
<camel:sslContextParameters id="ssl">
<camel:keyManagers keyPassword="password">
<camel:keyStore ... />
</camel:keyManagers>
<camel:trustManagers>
<camel:keyStore ... />
</camel:trustManagers>
</camel:sslContextParameters>
....
<rest path="/MyService" consumes="application/json" produces="application/json">
<post uri="/login">
<description>Authenticate User</description>
<route streamCache="true">
<to
uri="https4://domain-b:9000/Auth/user/login?bridgeEndpoint=true&sslContextParametersRef=ssl&x509HostnameVerifier=hostnameVerifier" />
</route>
</post>
...
</rest>
现在,就我的 to 端点中的 domain-b 进行硬编码,一切正常。当我必须从某个配置文件的输入中动态填充该值时,就会出现问题。
这就是我试图达到同样效果的方式 -
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
<property name="location" value="classpath:${LOCATION_PATH}propsfile.properties"/>
</bean>
属性键的名称是“域”,现在在我的端点定义中我写的是 -
<to
uri="https4://${properties.domain}:9000/Auth/user/login?bridgeEndpoint=true&sslContextParametersRef=ssl&x509HostnameVerifier=hostnameVerifier" />
基本上在加载名为 properties 的 bean 中的属性后,我尝试将 domain-b 替换为 ${properties.domain} 或 #{properties.domain},但似乎不起作用。
如果有人可以建议,仅在基于 XML 的配置中,我如何从属性文件中读取 URL 域,那将是非常棒的。
-AJ
【问题讨论】:
-
你试过
uri="https4://{{properties.domain}}:9000吗?内部骆驼路线元素属性可以这样使用。 -
让我检查并更新。谢谢
-
这样不行,还有其他建议吗?
标签: spring apache-camel