2.64. Ref
根据 Camel Registry 中的名称,将消息路由到端点动态查找。
2.64.1. 内部是什么 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
-
ref component, URI 语法:
ref:name
有关使用和配置详情,请参阅上述链接。
2.64.2. Maven 协调 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
在 code.quarkus.redhat.com 上使用此扩展创建一个新项目
或者将协调添加到现有项目中:
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-ref</artifactId>
</dependency>
2.64.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");
}
}