142.10. 呼び出し用の URI の設定
HTTP プロデューサーの URI はエンドポイント URI を直接形成できます。以下のルートでは、Camel は HTTP を使用して外部サーバー( 古いホスト
)に呼び出します。
from("direct:start") .to("http4://oldhost");
同等の Spring サンプルは次のとおりです。
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="direct:start"/> <to uri="http4://oldhost"/> </route> </camelContext>
HTTP エンドポイント URI を上書きするには、キー Exchange.HTTP_URI
でヘッダーをメッセージに追加します。
from("direct:start") .setHeader(Exchange.HTTP_URI, constant("http://newhost")) .to("http4://oldhost");
上記の例では、エンドポイントは http4://oldhost で設定されていても、Camel は http://newhost を呼び出します。
http4 エンドポイントがブリッジモードで動作している場合、Exchange.HTTP_URI
のメッセージヘッダーを無視します。