2.62. Ref
根据 Camel Registry 中的名称,将消息路由到端点动态查找。
2.62.1. 内部 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
-
ref component, URI syntax:
ref:name
有关用法和配置详情,请参阅上面的链接。
2.62.2. Maven 协调 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
在 code.quarkus.redhat.com 上使用此扩展创建一个新项目
或者在现有项目中添加协调:
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-ref</artifactId>
</dependency>
2.62.3. 使用 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
CDI 生成者方法可被利用来将端点绑定到 Camel registry,以便使用 Camel 路由中的 ref URI 方案解析它们。
例如,生成端点 Bean:
@ApplicationScoped
public class MyEndpointProducers {
@Inject
CamelContext context;
@Singleton
@Produces
@Named("endpoint1")
public Endpoint directStart() {
return context.getEndpoint("direct:start");
}
@Singleton
@Produces
@Named("endpoint2")
public Endpoint logEnd() {
return context.getEndpoint("log:end");
}
}
使用 ref: 引用绑定到 Camel registry 的 CDI Bean 的名称:
public class MyRefRoutes extends RouteBuilder {
@Override
public void configure() {
// direct:start -> log:end
from("ref:endpoint1")
.to("ref:endpoint2");
}
}