44.13. 配置 URI 来调用
您可以直接设置 HTTP producer 的 URI 组成端点 URI。在以下路由中,Camel 将使用 HTTP 调用外部服务器 oldhost
。
from("direct:start") .to("http://oldhost");
以及等同的 Spring 示例:
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="direct:start"/> <to uri="http://oldhost"/> </route> </camelContext>
您可以通过在消息中添加带有密钥 Exchange.HTTP_URI
的标头来覆盖 HTTP 端点 URI。
from("direct:start") .setHeader(Exchange.HTTP_URI, constant("http://newhost")) .to("http://oldhost");
在上面的 Camel 示例中,尽管端点配置了 http://newhost/,但其端点 会调用 http://oldhost/。
如果 http 端点在网桥模式下工作,它将忽略 Exchange.HTTP_URI
的消息标头。