1. 下载安装
1.1 安装配置JRE1.6
1.2 通过ServiceMix下载地址http://servicemix.apache.org/downloads.html下载apache-servicemix-5.4.0.zip。并解压。
1.3 进入apache-servicemix-5.4.0目录,使用./bin/servicemix (linux环境)启动服务。
2. camel demo
2.1 创建testfile.xml文件,如下。其作用是监听安装目录下camel/input文件夹中的文件,将文件传输至camel/output文件夹中。
<?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.2 将testfile.xml文件拷贝到安装目录deploy目录下。
2.3 通过osgi:list | grep testfile命令查看是否安装成功。
2.4 将需要传输的文件拷贝到camel/input后,服务会将文件自动传输至camel/output。
3. activemq demo
3.1 创建activemq_event.xml,其作用是将监听activemq/input文件夹将文件传输至activemmq/output文件夹中;通过事件监听文件传输事件。
<?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:activemq/input"/>
<to uri="file:activemq/output"/>
<setBody>
<simple>
FileMovedEvent(file: ${file:name}, timestamp: ${date:now:hh:MM:ss.SSS})
</simple>
</setBody>
<to uri="activemq://events" />
</route>
</camelContext>
</blueprint>
3.2 创建activemq_log.xml,监听activemq://events事件,输出日志。
<?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="activemq://events"/>
<to uri="log:events"/>
</route>
</camelContext>
</blueprint>
3.3 将activemq_event.xml与activemq_log.xml文件部署到deploy文件夹中,通过osgi:list | grep activemq查看是否部署成功。
3.4 测试将文件传输与消息传输后查看日志信息(log:list)。
4.feature install demo
4.1 通过features:list查看当前已经安装的feature.
4.2 通过features:install 安装,如安装webconsole使用features:install webconsole 命令。
4.3 安装完成后可通过http://localhost:8181/system/console/bundles 用户名:smx 密码:smx;访问服务中组建的运行情况并进行控制。