我想使用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」添加到發送給它的那個,並且完美運行。 –
在配置路由之前,我正在設置生產者模板並啓動駱駝上下文。順序是配置路由 - 駝峯上下文開始 - 生產者模板配置 –