我想使用Camel从ActiveMQ中接收消息,然后根据消息内容(protobuf)向Twitter发送一条或多条消息。我写了一个从路由中调用的bean,它使用注入将多个消息发送到“direct:xyz”端点。Apache Camel端点注入直接路由“没有终端用户可用”
然而,骆驼抱怨在运行时:
2012-11-16 09:56:33,376 | WARN | ication.twitter] | DirectProducer | 160 - org.apache.camel.camel-core - 2.10.2 | No consumers available on endpoint: Endpoint[direct://twitter] to process: Exchange[Message: hello world]
如果我不是从bean中直接注入到Twitter的端点,它工作正常。但是,为了简化测试,简化配置等,我想保持实际的Twitter配置不同,因此希望发送到单独的路由。
骆驼方面的配置是这样的: -
bean的样子: -
public class NotificationTweeter {
@EndpointInject(uri = "direct:twitter")
private ProducerTemplate producerTemplate;
public void createTweets(NotificationMsg notification) {
String tweet = notification.getMessageDetail().getTitle();
try {
// only send tweets where the notification message contains the Twitter mechanism
for (MechanismMsg mechanism : notification.getMechanismList()) {
if (mechanism.getType() == MechanismTypeEnum.TWITTER) {
// Cycle round the recipients
for (RecipientMsg recipient : mechanism.getRecipientList()) {
tweet = "@" + recipient.getIdentifier() + " " + tweet;
producerTemplate.sendBody(tweet);
}
// TODO exceptions if no recipients found, etc
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
我已经在其他途径(这个问题,肯定不是相关的Twitter功能),但刚刚解决它。然而,这次我真的想明白这个问题是什么!感激地收到了任何帮助,谢谢。
谢谢。我将startupOrder =“100”添加到直接路由,将“200”添加到发送给它的那个,并且完美运行。 –
在配置路由之前,我正在设置生产者模板并启动骆驼上下文。顺序是配置路由 - 驼峰上下文开始 - 生产者模板配置 –