在卡拉夫使用骆驼流

时间:2012-11-30 21:17:13

标签: apache-camel apache-karaf

我在karaf运行一个股票示例路线。我知道它正在工作,因为当我更改流:out to log:test时,我可以每隔5秒看到日志中的消息。但是,我似乎没有在karaf控制台中得到任何东西。我也安装了camel-stream,并且在日志中看不到任何错误。当我运行karaf bin / client时,我是否应该看到流:out数据?谢谢!

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<camelContext xmlns="http://camel.apache.org/schema/blueprint" id="simple">
<route>
    <from uri="timer:simple?period=5000"/>
        <setBody>
            <simple>Hello World</simple>
        </setBody>
    <to uri="stream:out"/>
 </route>
</camelContext>
</blueprint>

我在下面添加了功能信息。我现在正在使用karaf 2.2.9。我试过2.3.0:

karaf@root> features:list | grep stream
[installed  ] [2.9.4          ] camel-stream                             camel-2.9.4            
[uninstalled] [2.9.4          ] camel-xstream                         camel-2.9.4            
karaf@root> features:list | grep bluepr
[installed  ] [2.9.4          ] camel-blueprint                       camel-2.9.4            
[installed  ] [5.7.0          ] activemq-blueprint                    activemq-5.7.0         
karaf@root> ^D

我也尝试了以下内容:

service KARAF-service stop
cd /usr/local/karaf
rm -rf data/cache/*
service KARAF-service start
echo "features:install camel-blueprint camel-stream" | bin/client
cp /root/simple-camel-blueprint.xml  deploy/  && tail -f data/log/karaf.log

我明白了:

***deleted startup messages***
2012-12-01 14:56:42,166 | INFO  | - timer://simple | test                             | 64 - org.apache.camel.camel-core - 2.9.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:Hello World]
2012-12-01 14:56:47,134 | INFO  | - timer://simple | test                             | 64 - org.apache.camel.camel-core - 2.9.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:Hello World]
2012-12-01 14:56:52,135 | INFO  | - timer://simple | test                             | 64 - org.apache.camel.camel-core - 2.9.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:Hello World]
2012-12-01 14:56:57,135 | INFO  | - timer://simple | test                             | 64 - org.apache.camel.camel-core - 2.9.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:Hello World]
2012-12-01 14:57:02,135 | INFO  | - timer://simple | test                             | 64 - org.apache.camel.camel-core - 2.9.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:Hello World]
2012-12-01 14:57:07,136 | INFO  | - timer://simple | test                             | 64 - org.apache.camel.camel-core - 2.9.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:Hello World]
2012-12-01 14:57:12,135 | INFO  | - timer://simple | test                             | 64 - org.apache.camel.camel-core - 2.9.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:Hello World]
2012-12-01 14:57:17,135 | INFO  | - timer://simple | test                             | 64 - org.apache.camel.camel-core - 2.9.4 | Exchange[ExchangePattern:InOnly, BodyType:String, Body:Hello World]

如果我将'to uri'从“log:test”更改为“stream:out”,那么运行bin / client我什么也得不到。是一个有效的控制台输出测试?

我也应该加上这个:

karaf@root> camel:route-info route3
Camel Route route3
    Camel Context: simple

Properties 
        id = route3
        parent = 7fcb9c0a

Statistics
    Exchanges Total: 5
    Exchanges Completed: 5
    Exchanges Failed: 0
    Min Processing Time: 1ms
    Max Processing Time: 5ms
    Mean Processing Time: 1ms
    Total Processing Time: 9ms
    Last Processing Time: 1ms
    Load Avg: 0.00, 0.00, 0.00
    First Exchange Date: 2012-12-01 15:08:32
    Last Exchange Completed Date: 2012-12-01 15:08:52

Definition
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<route id="route3" xmlns="http://camel.apache.org/schema/spring">
    <from uri="timer:simple?period=5000"/>
    <setBody id="setBody3">
        <simple>Hello World</simple>
    </setBody>
    <to uri="stream:out" id="to3"/>
</route>

1 个答案:

答案 0 :(得分:1)

你使用哪种Camel和Karaf版本?

你有安装camel-stream功能吗?在安装和启动自己的软件包之前,您需要这样做。