使用带有 @EndpointInject 的 Camel Endpoint DSL 创建不同的端点
Using Camel Endpoint DSL with @EndpointInject creating different endpoints
使用端点 DSL 然后使用 ProducerTemplate 引用端点的正确方法是什么?创建路由并使用端点 DSL 时,Camel 似乎正在为端点创建不同的 uri。我的 EndpointRouteBuilder class:
@Component
public class MyRoutes extends EndpointRouteBuilder {
@Override
public void configure() throws Exception {
from(seda("STATUS_ENDPOINT"))
.routeId("stateChangeRoute")
.to(activemq("topic:statusTopic"))
}
}
然后将端点注入 ProducerTemplate
@Component
public class StateChangePublisher {
@EndpointInject(value="seda:STATUS_ENDPOINT")
private ProducerTemplate producer;
public void publish(String str) {
try {
producer.sendBody(str);
} catch(CamelExecutionException e) {
e.printStackTrace();
}
}
}
当 camel 启动时,我在日志中看到两个条目:
o.a.camel.component.seda.SedaEndpoint : Endpoint seda:STATUS_ENDPOINT is using shared queue: seda:STATUS_ENDPOINT with size: 1000
o.a.camel.component.seda.SedaEndpoint : Endpoint seda://STATUS_ENDPOINT is using shared queue: seda://STATUS_ENDPOINT with size: 1000
队列最终填满,没有任何东西被传送到 "to" 端点。
如果我在不使用端点 DSL 方法的情况下定义路由 "seda()"
from("seda:STATUS_ENDPOINT")
然后就可以了。
这是一个错误还是我做错了什么?
我正在使用骆驼 3.2.0 和
这是端点 dsl 中的错误。尝试升级到骆驼 3.3.0。我认为它已在新版本中修复。
使用端点 DSL 然后使用 ProducerTemplate 引用端点的正确方法是什么?创建路由并使用端点 DSL 时,Camel 似乎正在为端点创建不同的 uri。我的 EndpointRouteBuilder class:
@Component
public class MyRoutes extends EndpointRouteBuilder {
@Override
public void configure() throws Exception {
from(seda("STATUS_ENDPOINT"))
.routeId("stateChangeRoute")
.to(activemq("topic:statusTopic"))
}
}
然后将端点注入 ProducerTemplate
@Component
public class StateChangePublisher {
@EndpointInject(value="seda:STATUS_ENDPOINT")
private ProducerTemplate producer;
public void publish(String str) {
try {
producer.sendBody(str);
} catch(CamelExecutionException e) {
e.printStackTrace();
}
}
}
当 camel 启动时,我在日志中看到两个条目:
o.a.camel.component.seda.SedaEndpoint : Endpoint seda:STATUS_ENDPOINT is using shared queue: seda:STATUS_ENDPOINT with size: 1000
o.a.camel.component.seda.SedaEndpoint : Endpoint seda://STATUS_ENDPOINT is using shared queue: seda://STATUS_ENDPOINT with size: 1000
队列最终填满,没有任何东西被传送到 "to" 端点。 如果我在不使用端点 DSL 方法的情况下定义路由 "seda()"
from("seda:STATUS_ENDPOINT")
然后就可以了。 这是一个错误还是我做错了什么? 我正在使用骆驼 3.2.0 和
这是端点 dsl 中的错误。尝试升级到骆驼 3.3.0。我认为它已在新版本中修复。