51.5. 运行时查找
当您需要动态发现 Registry 中的端点时,可以使用此组件,您可以在其中在运行时计算 URI。然后您可以使用以下代码查找端点:
// lookup the endpoint
String myEndpointRef = "bigspenderOrder";
Endpoint endpoint = context.getEndpoint("ref:" + myEndpointRef);
Producer producer = endpoint.createProducer();
Exchange exchange = producer.createExchange();
exchange.getIn().setBody(payloadToSend);
// send the exchange
producer.process(exchange);
并且您可以在 Registry 中定义端点列表,例如:
<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<endpoint id="normalOrder" uri="activemq:order.slow"/>
<endpoint id="bigspenderOrder" uri="activemq:order.high"/>
</camelContext>