Spring 如何在apache camel XML配置中使用URI端点中的动态值
我使用ApacheCamel在端点之间创建路由,通过在一个端口上运行在Tomcat上的一个URI(API网关),我映射到在不同域和端口上运行在Tomcat上的另一个URISpring 如何在apache camel XML配置中使用URI端点中的动态值,spring,apache-camel,Spring,Apache Camel,我使用ApacheCamel在端点之间创建路由,通过在一个端口上运行在Tomcat上的一个URI(API网关),我映射到在不同域和端口上运行在Tomcat上的另一个URI <bean id="hostnameVerifier" class="org.apache.http.conn.ssl.AllowAllHostnameVerifier" /> ... <camel:sslContextParameters id="ssl"> <camel:keyMana
<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端点中对域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中之后,我试图用${properties.domain}或#{properties.domain}替换domain-b,但似乎不起作用
如果有人能建议(仅在基于XML的配置中)如何从属性文件中读取URL域,那将非常棒
-AJ您必须使用属性占位符以您想要的方式实现动态uri 例如:
<camelContext ...>
<propertyPlaceholder id="properties" location="YOUR_PROPERTY_FILE_LOCATION"/>
</camelContext>
然后试着用
<to uri="https4://{{properties.domain}}:9000/.......>
自驼峰2.16以来的
我们可以使用
.from("file://path")
.toD("file://folder/${file:onlyname}")
我们可以使用文件您是否尝试过uri=“https4://{{properties.domain}}}:9000
?驼峰路线内的元素属性是这样的。让我检查并更新。谢谢您没有这样做,还有其他建议吗?