【发布时间】:2014-03-31 05:46:11
【问题描述】:
我想在 HTTP 端点中外部化主机名和端口号,所以我试图在启动 ESB 时在 JVM 参数中传递主机名和端口号。 使用脚本/类中介,我可以从系统属性中获取它并将其放入消息上下文中。然后使用属性中介,我可以访问并记录它的值。 到目前为止,我没有任何问题,但是当我尝试使用此值替换 HTTP 端点时,如下所示;它不起作用。
实际的 ESB Synapse API 配置:
<api xmlns="http://ws.apache.org/ns/synapse" name="ContentLength" context="/content">
<resource methods="GET">
<inSequence>
<send>
<endpoint>
<http method="get" uri-template="http://198.160.1.223:8080/greeting/{uri.var.name}"></http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send></send>
</outSequence>
</resource>
</api>
预期的 ESB Synapse API 配置:
<api xmlns="http://ws.apache.org/ns/synapse" name="ContentLength" context="/content">
<resource methods="GET">
<inSequence>
<script language="js">mc.setProperty("system.hostname",java.lang.System.getProperty("my.hostname"));mc.setProperty("system.port.no",java.lang.System.getProperty("my.port.no"));</script>
<log level="custom">
<property name="system.hostname" expression="get-property('system.hostname')"/>
<property name="system.port.no" expression="get-property('system.port.no')"/>
</log>
<send>
<endpoint>
<http method="get" uri-template="http://{system.prop.my.hostname}:{system.prop.my.port.no}/greeting/{uri.var.name}"></http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send></send>
</outSequence>
</resource>
</api>
在这种情况下有什么方法可以使用模板端点和 HTTP 端点?
也让我知道其他选择。
【问题讨论】: