3.10. 配置要调用的 URI
您可以直接设置 HTTP producer 的 URI,即端点 URI。在以下路由中,Camel 使用 HTTP 调用外部服务器 oldhost
。
from("direct:start") .to("ahc:http://oldhost");
以及对等的 Spring 示例:
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="direct:start"/> <to uri="ahc:http://oldhost"/> </route> </camelContext>
您可以通过在消息中添加带有密钥 Exchange.HTTP_URI
的标头来覆盖 HTTP 端点 URI。
from("direct:start") .setHeader(Exchange.HTTP_URI, constant("http://newhost")) .to("ahc:http://oldhost");