1、創建一個xml
在
ServiceMix中定義一個新的 route,最簡單的方式之一就是定義一個Blueprint XML file,就像下邊一樣:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="file:camel/input"/>
<log message="Moving ${file:name} to the output directory"/>
<to uri="file:camel/output"/>
</route>
</camelContext>
</blueprint>
2.部署
我們只需要將第一步創建的xml復制到serviceMix下的 deploy 目錄,就會被serviceMix 識別并部署。你會看到被放到目錄camel/input下的文件被
移動到camel/output,如果你使用log:display命令,會看到文件移動的日志:2015-04-09 17:10:19,515 | INFO | le://camel/input | route1
| ? ? | 116 - org.apache.camel.camel-cor
e - 2.14.1 | Moving test.xml.bak to the output directory
3. 使用命令行管理 route使用osgi:list,你會看到剛才我們部署的bundle
[ 221] [Active ] [Created ] [ ] [ 80] test.xml (0.0.0)
你會看到我們剛才部署的bundle ID是221,我們可以通過這個bundle ID來啟動或者關閉bundle
karaf@root> osgi:stop 221
karaf@root> osgi:start 221