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