我是 Camel 的新手,正在尝试设置一个非常简单的应用程序来习惯它,我正在运行以下代码:
CamelContext cc = (CamelContext)ac.getBean("testCamelContext");
ProducerTemplate template = cc.createProducerTemplate();
System.out.println("Sending Message Body");
template.sendBody("seda:testProducer", "hello");
System.out.println("Sent");
运行良好,但我的消费者似乎从未收到消息,我在控制台上得到以下信息:
[ main] SpringCamelContext INFO Apache Camel 2.10.2 (CamelContext: testCamelContext) is starting
[ main] ManagementStrategyFactory INFO JMX enabled.
[ main] DefaultTypeConverter INFO Loaded 172 type converters
[ main] SpringCamelContext INFO Route: route1 started and consuming from: Endpoint[seda://testProducer]
[ main] ultManagementLifecycleStrategy INFO StatisticsLevel at All so enabling load performance statistics
[ main] SpringCamelContext INFO Total 1 routes, of which 1 is started.
[ main] SpringCamelContext INFO Apache Camel 2.10.2 (CamelContext: testCamelContext) started in 0.373 seconds
Init Context
SendingMessage
Sending Message Body
Sent
使用以下骆驼上下文:
<camel:camelContext id="testCamelContext">
<camel:routeBuilder ref="testCamelRouteBuilder"/>
</camel:camelContext>
和 RouteBuilder 规则:
from("seda:testProducer").beanRef("testConsumer","consumeMessage");
以及以下消费者 bean:
public class TestConsumer {
public void consumeMessage(String msg)
{
System.out.println("Message: " + msg);
}
}
所有的豆子都很好,骆驼似乎可以检测到规则,所以我不确定我做错了什么。我显然没有正确使用某些东西?