吳密的博客

          每天進(jìn)步一點(diǎn)點(diǎn)
          posts - 12, comments - 1, trackbacks - 0, articles - 1

          2010年2月23日

          在本章我們介紹在serviceMIx 中圖和使用 ActiveMQ、features命令,入門的3篇文章來(lái)自
          http://servicemix.apache.org/docs/5.0.x/quickstart/index.html,有興趣的可以再去看看英文的。

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

             保存這個(gè)文件,并且放到serviceMix的deploy目錄,會(huì)看到復(fù)制到 activemq/input 目錄中的文件被復(fù)制到 activemq/output 

             接受消息
             在第一個(gè)文件中,除了復(fù)制文件,你看不到任何的log記錄。它發(fā)送了jms消息,但是沒(méi)有接受者,我們可以創(chuàng)建一個(gè)route來(lái)接受消息:

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

            你可以通過(guò)log:display來(lái)查看日志消息。你可以通過(guò)osgi:start 和 osgi:stop來(lái)啟動(dòng)和關(guān)閉這個(gè)bundle.當(dāng)你重啟完第一個(gè)bundle后,你收到所有文件移動(dòng)后發(fā)出
          的消息事件。

              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

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

          posted @ 2015-04-10 15:37 xiaolang 閱讀(5172) | 評(píng)論 (0)編輯 收藏

          本章我們通過(guò)一個(gè)簡(jiǎn)單的實(shí)例來(lái)介紹如何使用camel。
          這個(gè)實(shí)例中,我們會(huì)把文件從目錄
          camel/input 移動(dòng)到camel/output.為了方便我們跟蹤哪些文件被移動(dòng),我們會(huì)記錄日志。

          1、創(chuàng)建一個(gè)xml
           ServiceMix中定義一個(gè)新的 route,最簡(jiǎn)單的方式之一就是定義一個(gè)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.部署
             我們只需要將第一步創(chuàng)建的xml復(fù)制到serviceMix下的 deploy 目錄,就會(huì)被serviceMix 識(shí)別并部署。你會(huì)看到被放到目錄camel/input下的文件被
          移動(dòng)到camel/output,如果你使用log:display命令,會(huì)看到文件移動(dòng)的日志:

          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,你會(huì)看到剛才我們部署的bundle
          [ 221] [Active     ] [Created     ] [       ] [   80] test.xml (0.0.0)
          你會(huì)看到我們剛才部署的bundle ID是221,我們可以通過(guò)這個(gè)bundle ID來(lái)啟動(dòng)或者關(guān)閉bundle

          karaf@root> osgi:stop 221
          karaf@root> osgi:start 221

          posted @ 2015-04-09 17:19 xiaolang 閱讀(4486) | 評(píng)論 (0)編輯 收藏

          本章我們主要介紹下如何安裝serviceMiX,使用命令來(lái)查看osgi bundles、日志。

          1、下載
          serviceMiX5.4.0
          http://servicemix.apache.org/downloads.html
          到下載頁(yè)面選取:
          tar,gz  for Linux/Unix/MacOS X
          zip for windows

          如果僅僅是運(yùn)行
          serviceMiX,你需要jre1.6.x 或者 jre1.7.x  serviceMiX5.4.0大概需要100M的空間
          如果你要開發(fā)自己的一些集成應(yīng)用和osgi bundles,你還需要安裝  jdk1.6.x 或者 jdk1.7.x  apache maven3.0.4 或者更高的版本


          2.解壓,指定<SERVICEMIX_HOME>.
          解壓,在環(huán)境變量中配置 <SERVICEMIX_HOME>.例如:C:\apache-servicemix

          3.啟動(dòng)serviceMiX(windows)

          C:\Users\Administrator>cd c:\apache-servicemix\bin

          c:\apache-servicemix\bin>servicemix
          Please wait while Apache ServiceMix is starting...
           27% [===================>                                                    ]


          4.啟動(dòng)成功

          Please wait while Apache ServiceMix is starting...
          100% [========================================================================]
           ____                  _          __  __ _
          / ___|  ___ _ ____   _(_) ___ ___|  \/  (_)_  __
          \___ \ / _ \ '__\ \ / / |/ __/ _ \ |\/| | \ \/ /
           ___) |  __/ |   \ V /| | (_|  __/ |  | | |>  <
          |____/ \___|_|    \_/ |_|\___\___|_|  |_|_/_/\_\
            Apache ServiceMix (5.4.0)
          Hit '<tab>' for a list of available commands
          and '[cmd] --help' for help on a specific command.
          Hit '<ctrl-d>' or 'osgi:shutdown' to shutdown ServiceMix.

          5. 
          使用命令 osgi:list  osgi:list|grep camel 查看bundles 

          karaf@root> osgi:list
          START LEVEL 100 , List Threshold: 50
             ID   State         Blueprint      Spring    Level  Name
          [  81] [Active     ] [            ] [       ] [   50] geronimo-annotation_1.0_spec (1.1.1)
          [  82] [Active     ] [            ] [       ] [   50] geronimo-jms_1.1_spec (1.1.1)
          [  83] [Active     ] [            ] [       ] [   50] geronimo-j2ee-management_1.1_spec (1.0.1)
          [  84] [Active     ] [            ] [       ] [   50] JAXB2 Basics - Runtime (0.6.4)
          [  85] [Active     ] [            ] [       ] [   50] Apache ServiceMix :: Bundles :: jaxb-impl (2.2.1.1_2)

          karaf@root> osgi:list|grep camel
          [ 116] [Active     ] [            ] [       ] [   50] camel-core (2.14.1)
          [ 117] [Active     ] [Created     ] [       ] [   50] camel-karaf-commands (2.14.1)
          [ 118] [Active     ] [            ] [       ] [   50] camel-jms (2.14.1)
          [ 124] [Active     ] [            ] [       ] [   50] camel-spring (2.14.1)
          [ 125] [Active     ] [Created     ] [       ] [   50] camel-blueprint (2.14.1)

          6.
          使用log:display查看日志,其他 log:display-exception

          karaf@root> log:display
          2015-04-09 16:09:07,433 | INFO  | 0 - timer://wumi | timerToLog  | ?                                   ? | 116 - org.apache.camel.camel-cor
          e - 2.14.1 | The message contains Hi from Camel at 2015-04-09 16:09:07

          posted @ 2015-04-09 16:25 xiaolang 閱讀(6359) | 評(píng)論 (1)編輯 收藏

          今天下午發(fā)現(xiàn)mysql客戶端連接服務(wù)端緩慢,windows 環(huán)境下,到目錄 MYSQL_HOME/my.ini 中加入:skip-name-resolve,然后保存并重啟mysql服務(wù)

          問(wèn)題解決。

          查閱mysql官方網(wǎng)站得知,這屬于官方一個(gè)系統(tǒng)上的特殊設(shè)定,就把他當(dāng)成mysql的一個(gè)bug算了,不管鏈接的的方式是經(jīng)過(guò) hosts 或是 IP 的模式,他都會(huì)對(duì) DNS
          做反查。mysqld 會(huì)嘗試去反查 IP -> dns ,由于反查解析過(guò)慢,就會(huì)無(wú)法應(yīng)付過(guò)量的查詢。





          posted @ 2015-04-01 17:24 xiaolang 閱讀(337) | 評(píng)論 (0)編輯 收藏

          布局介紹:
          http://penguin7.blog.51cto.com/966026/222075


          簽名介紹:

          posted @ 2011-01-18 09:50 xiaolang 閱讀(255) | 評(píng)論 (0)編輯 收藏

               摘要: 1、訪問(wèn)we.alipay.com ,使用支付寶賬戶登錄,輸入團(tuán)體收款“邀請(qǐng)碼”(我們定向派發(fā)了第一批邀請(qǐng)碼300個(gè))開通團(tuán)長(zhǎng)功能。

          2、體驗(yàn)一下“團(tuán)體收款”的各種功能,不管是不爽,還是滿意,都請(qǐng)您提交“用戶反饋”:
          ? 可以試試創(chuàng)建一個(gè)團(tuán)體,拉你的好友成為團(tuán)員;
          ? 可以在成功創(chuàng)建團(tuán)體后,試著發(fā)起各類活動(dòng)收款;
          ? 您會(huì)經(jīng)常在哪些活動(dòng)中遇到和使用一對(duì)多的團(tuán)體收款?
          ? 您身邊使用支付寶的好友多嗎?
          ? 我們這個(gè)新生產(chǎn)品可以幫助您把團(tuán)體活動(dòng)收款變簡(jiǎn)單嗎?
          QQ: 908820222  閱讀全文

          posted @ 2011-01-07 17:37 xiaolang 閱讀(313) | 評(píng)論 (0)編輯 收藏

               摘要:   閱讀全文

          posted @ 2011-01-06 18:38 xiaolang 閱讀(2562) | 評(píng)論 (0)編輯 收藏

               摘要: 寫代碼是一個(gè)富有創(chuàng)意但又可能讓人思想麻痹的任務(wù),不管你是否喜歡你的工作,你總會(huì)找一些捷徑,但遺憾的是,大部分捷徑都違反了最佳編碼實(shí)踐原則,這些捷徑要么會(huì)產(chǎn)生BUG,要么會(huì)導(dǎo)致數(shù)據(jù)出錯(cuò),我的建議是:在編寫VBA代碼時(shí),不要走捷徑。下面是一些常見的錯(cuò)誤觀念,導(dǎo)致人們選擇了錯(cuò)誤的捷徑,雖然其中一部分只適用于VBA或某種IDE,但大多數(shù)都是通用的  閱讀全文

          posted @ 2010-12-06 09:34 xiaolang 閱讀(233) | 評(píng)論 (0)編輯 收藏

               摘要: 使用Jmock時(shí),如果給的類型不是一個(gè)接口的時(shí)候,會(huì)拋出一個(gè)異常xxx is not an interface。其實(shí)根據(jù)Jmock的文檔,只要稍作修改,就可以解決這個(gè)問(wèn)題。
            閱讀全文

          posted @ 2010-09-29 13:27 xiaolang 閱讀(387) | 評(píng)論 (0)編輯 收藏

               摘要: 使用threadLoca做一個(gè)簡(jiǎn)單的本地緩存l  閱讀全文

          posted @ 2010-09-10 13:44 xiaolang 閱讀(5650) | 評(píng)論 (0)編輯 收藏

               摘要: 一提到文檔,肯定會(huì)有人向你大談外國(guó)公司、大公司、正規(guī)公司是怎么怎么重視文檔的,什么2/3時(shí)間用于寫文檔,1/3時(shí)間才用來(lái)編程序;寫文檔要按照什么ISO、什么CMM、什么什么標(biāo)準(zhǔn);不按這些標(biāo)準(zhǔn)寫出來(lái)的就不是文檔,就不是好文檔  閱讀全文

          posted @ 2010-07-09 12:11 xiaolang 閱讀(255) | 評(píng)論 (0)編輯 收藏

          在我們現(xiàn)在系統(tǒng)的代碼中,存在很多類似的代碼,這個(gè)接口大家都應(yīng)該認(rèn)得,是spring預(yù)留的接口

          在所有的bean加載完畢后執(zhí)行。

             /** 
               * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
               */
              public void afterPropertiesSet() throws Exception {

                1. 從其他系統(tǒng)加載數(shù)據(jù)

                2.如果加載失敗,直接拋異常,系統(tǒng)不啟動(dòng)
              }

          在這個(gè)過(guò)程中,如果被加載的系統(tǒng)掛掉了,這個(gè)系統(tǒng)暫時(shí)就啟動(dòng)不了。

          其實(shí)這是系統(tǒng)間的一種依賴,這樣就要求系統(tǒng)A啟動(dòng)之后,系統(tǒng)B才能啟動(dòng),1,2個(gè)系統(tǒng)還好說(shuō),如果系統(tǒng)多

          了系統(tǒng)的啟動(dòng)順序就比較難以控制,發(fā)布的難度就會(huì)增大(當(dāng)然,系統(tǒng)的啟動(dòng)順序不只光跟這個(gè)有關(guān)系)。

          大家這樣做的目的無(wú)非有(大家也可以補(bǔ)充):

          1.性能方面的問(wèn)題,某些數(shù)據(jù)相對(duì)來(lái)說(shuō)是不經(jīng)常變化的,當(dāng)前系統(tǒng)只有很少一部分模塊會(huì)使用這部分?jǐn)?shù)據(jù),

          只需要系統(tǒng)啟動(dòng)的時(shí)候,到其他系統(tǒng)取一遍,放到內(nèi)存中,減少遠(yuǎn)程調(diào)用的次數(shù);

          2.當(dāng)前系統(tǒng)確實(shí)需要依賴另外一個(gè)系統(tǒng)的數(shù)據(jù),如果沒(méi)有這部分?jǐn)?shù)據(jù),系統(tǒng)將無(wú)法進(jìn)行后續(xù)的業(yè)務(wù);

          對(duì)于第二種情況,確實(shí)是需要這樣做的,如果是第一種情況,我們可以這樣做

          系統(tǒng)數(shù)據(jù)  a = null;

          if(null == a){

              a =  系統(tǒng)B的查詢結(jié)果

          }

          return a

           

          如果有2個(gè)系統(tǒng),這樣做的話,單純對(duì)第一種情況來(lái)說(shuō),這個(gè)2個(gè)系統(tǒng)是可以同時(shí)啟動(dòng)的,從一定程度上

          降低了系統(tǒng)間的依賴;但是如果在啟動(dòng)時(shí)加載的話,就必須第一個(gè)系統(tǒng)成功的啟動(dòng)起來(lái)。

          posted @ 2010-02-23 17:20 xiaolang 閱讀(177) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 枣阳市| 玉溪市| 浦东新区| 鞍山市| 张家港市| 迁安市| 确山县| 读书| 水富县| 高雄市| 利辛县| 甘孜县| 乐至县| 泾川县| 崇信县| 和硕县| 南皮县| 梅河口市| 阜平县| 民勤县| 筠连县| 九江市| 平泉县| 阿勒泰市| 桃江县| 永嘉县| 彭水| 张家界市| 永和县| 舞钢市| 张家口市| 疏勒县| 永安市| 冕宁县| 沙湾县| 乌拉特前旗| 鄂伦春自治旗| 台北县| 新乐市| 临城县| 道真|