吳密的博客

          每天進步一點點
          posts - 12, comments - 1, trackbacks - 0, articles - 1

          serviceMiX入門二(Routing with Camel)

          Posted on 2015-04-09 17:19 xiaolang 閱讀(4485) 評論(0)  編輯  收藏
          本章我們通過一個簡單的實例來介紹如何使用camel。
          這個實例中,我們會把文件從目錄
          camel/input 移動到camel/output.為了方便我們跟蹤哪些文件被移動,我們會記錄日志。

          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

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 肥东县| 临洮县| 宁阳县| 从江县| 福清市| 榕江县| 山西省| 苍山县| 德江县| 旅游| 彭水| 定州市| 行唐县| 襄汾县| 黄浦区| 平江县| 方正县| 德州市| 页游| 象州县| 崇仁县| 房山区| 简阳市| 肥东县| 巢湖市| 交口县| 孝感市| 察隅县| 庆安县| 西乡县| 奉贤区| 淮阳县| 泸水县| 长治县| 三门峡市| 邵阳市| 祁东县| 阳信县| 丹江口市| 防城港市| 清涧县|