Apache ServiceMix入门

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;访问服务中组建的运行情况并进行控制。



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值