吳密的博客

          每天進步一點點
          posts - 12, comments - 1, trackbacks - 0, articles - 1
          在本章我們介紹在serviceMIx 中圖和使用 ActiveMQ、features命令,入門的3篇文章來自
          http://servicemix.apache.org/docs/5.0.x/quickstart/index.html,有興趣的可以再去看看英文的。

          ActiveMQ
              每個
          Apache ServiceMix的實例是一個嵌入式activemq jms代理,這樣可以很方便的在同一臺機器上使用持久消息來通信,
          但是它也支持集群和負載均衡。
             在這個實例中,我們依然像上個例子一樣,在2個目錄中移動文件,把記錄日志的部分改為發送一條jms消息到消息隊列,
          然后再創建一個新的route來接受事件并記錄日志:
          ?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>

             保存這個文件,并且放到serviceMix的deploy目錄,會看到復制到 activemq/input 目錄中的文件被復制到 activemq/output 

             接受消息
             在第一個文件中,除了復制文件,你看不到任何的log記錄。它發送了jms消息,但是沒有接受者,我們可以創建一個route來接受消息:

          <?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>

            你可以通過log:display來查看日志消息。你可以通過osgi:start 和 osgi:stop來啟動和關閉這個bundle.當你重啟完第一個bundle后,你收到所有文件移動后發出
          的消息事件。

              features命令

          karaf@root> features:list | grep camel
          [uninstalled] [5.4.0           ] examples-activiti-camel                 servicemix-examples-5.4.0
          [uninstalled] [5.4.0           ] examples-akka-camel                     servicemix-examples-5.4.0


          karaf@root> features:install webconsole

          karaf@root> features:list | grep webconsole
          [installed  ] [2.4.1           ] webconsole                              karaf-2
          .4.1               Karaf WebConsole for administration and monitoring

              通過features:install webconsole可以安裝  webconsole bundle,成功后你可以通過  http://localhost:8181/system/console  用戶名密碼:smx/smx來
          登錄
          ,可以通過瀏覽器來上傳、啟動,停止bundle。


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


          網站導航:
           
          主站蜘蛛池模板: 鹤山市| 邯郸市| 上犹县| 周至县| 绩溪县| 明光市| 米泉市| 华安县| 阳曲县| 莆田市| 灌阳县| 江口县| 维西| 武邑县| 多伦县| 霸州市| 温泉县| 襄樊市| 林甸县| 高平市| 鲁甸县| 团风县| 濮阳县| 赤城县| 大英县| 林口县| 元阳县| 定南县| 红河县| 凌海市| 平乐县| 平山县| 穆棱市| 乡城县| 罗平县| 陵水| 离岛区| 贡山| 泽州县| 阿巴嘎旗| 东丰县|