Red Hat Training

A Red Hat training course is available for Red Hat Fuse

3.9. 呼び出す URI の設定

HTTP プロデューサーの 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");