<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    itstarting:IT進行時

    想自己所想,做自己所愛

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      28 隨筆 :: 3 文章 :: 55 評論 :: 0 Trackbacks
     

    ActiveMQ 5.0的文檔實在是太少了,尤其是集成Spring2.x方面更少。

            下面是配置方面的心得:
            一、服務器端配置:

     總體參考官方網站進行整合,差點害死人,不停的出現各種配置錯誤,后來經過google查詢各種郵件列表,才發現xsd使用不當。        

    <?xml version="1.0" encoding="UTF-8"?>
    <beans 
      
    xmlns="http://www.springframework.org/schema/beans" 
      xmlns:amq
    ="http://activemq.org/config/1.0"
      xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation
    ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://activemq.org/config/1.0 http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd"
    >


    </beans>

    這個才是正確的,兩點:

    1、去掉:

    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    2、用這個而不是那個:

    這個:

               http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd

    那個:     
         http://activemq.apache.org/snapshot-schema/activemq-core-5.0-SNAPSHOT.xsd


            完整的配置如下:        
            applicationContext-activeMQ.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans 
      
    xmlns="http://www.springframework.org/schema/beans" 
      xmlns:amq
    ="http://activemq.org/config/1.0"
      xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation
    ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://activemq.org/config/1.0 http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd"
    >

      
    <amq:broker useJmx="true" persistent="true"> 
        
    <amq:persistenceAdapter> 
            
    <amq:jdbcPersistenceAdapter dataSource="#mysql-ds"/> 
          
    </amq:persistenceAdapter> 
        
    <amq:transportConnectors> 
           
    <amq:transportConnector uri="tcp://localhost:0"/> 
        
    </amq:transportConnectors> 
       
    </amq:broker>
      
      
    <!-- MySql DataSource Setup -->
      
    <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        
    <property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/>
        
    <property name="username" value="activemq"/>
        
    <property name="password" value="activemq"/>
        
    <!--
        <property name="poolPreparedStatements" value="true"/>
    -->
      
    </bean>
    </beans>


            二、web.xml配置: 

        <!--activeMQ-->
        
    <context-param>
            
    <param-name>contextConfigLocation</param-name>
            
    <param-value>
                /WEB-INF/applicationContext-activeMQ.xml 
                /WEB-INF/applicationContext-jms.xml 
            
    </param-value>
        
    </context-param>

        
    <listener>
            
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        
    </listener>



            三、客戶端配置此處僅供參考,還未曾具體實戰確認):
            applicationContext-jms.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans 
      
    xmlns="http://www.springframework.org/schema/beans" 
      xmlns:amq
    ="http://activemq.org/config/1.0"
      xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation
    ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://activemq.org/config/1.0 http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd"
    >
      
    <!-- ActiveMQ destinations to use  -->
      
    <amq:queue id="destination"  physicalName="org.apache.activemq.spring.Test.spring.embedded"/>

      
    <!-- JMS ConnectionFactory to use, configuring the embedded broker using XML -->
      
    <amq:connectionFactory id="jmsFactory" brokerURL="vm://localhost"/>  
      
    <!-- Spring JMS Template -->
      
    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        
    <property name="connectionFactory">
          
    <!-- lets wrap in a pool to avoid creating a connection per send -->
          
    <bean class="org.springframework.jms.connection.SingleConnectionFactory">
            
    <property name="targetConnectionFactory">
              
    <ref bean="jmsFactory" />
            
    </property>
          
    </bean>
        
    </property>
        
    <property name="messageConverter">
            
    <ref bean="dynamicMessageConverter"/>
        
    </property>
      
    </bean>
      
      
    <bean id="dynamicMessageConverter" class="com.tuanzi.message.mq.impl.DynamicMessageConverter"/>  

      
    <bean id="consumerJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        
    <property name="connectionFactory">
            
    <ref bean="jmsFactory"/>
        
    </property>
        
    <property name="messageConverter">
            
    <ref bean="dynamicMessageConverter"/>
        
    </property>
        
    <property name="receiveTimeout">
            
    <value>10000</value>
        
    </property>
      
    </bean>

      
    <!-- a sample POJO which uses a Spring JmsTemplate -->
      
    <bean id="simpleMessageProducer" class="com.tuanzi.message.mq.impl.SimpleMessageProducer">
        
    <property name="jmsTemplate">
          
    <ref bean="jmsTemplate"></ref>
        
    </property>
        
    <property name="destination">
          
    <ref bean="destination" />
        
    </property>
      
    </bean>

      
    <!-- a sample POJO consumer -->
      
    <bean id="simpleMessageConsumer" class="com.tuanzi.message.mq.impl.SimpleMessageConsumer">
        
    <property name="jmsTemplate" ref="consumerJmsTemplate"/>
        
    <property name="destination" ref="destination"/>
      
    </bean>
    </beans>


        TODO:
        1、客戶端的配置需要實戰后進行進一步的確認、更新;
        2、后期視情況增加一篇《Spring2.x與ActiveMQ5.0成功集成的心得(實戰篇)》


        主要參考:

    http://activemq.apache.org/spring-support.html

    http://activemq.apache.org/xml-reference.html

    posted on 2008-01-20 23:41 IT進行時 閱讀(3437) 評論(3)  編輯  收藏 所屬分類: Java Tips

    評論

    # re: Spring2.x與ActiveMQ5.0成功集成的心得(配置篇) 2008-01-21 11:23 genjuro
    我是直接從它的svn取測試的源碼和配置文件來用

    https://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/spring/
    https://svn.apache.org/repos/asf/activemq/trunk/activemq-core/src/test/resources/

    試過spring.xml,spring-queue.xml和spring-embedded.xml,都可以用

    但還沒搞清楚這些配置文件之間的區別:(  回復  更多評論
      

    # re: Spring2.x與ActiveMQ5.0成功集成的心得(配置篇) 2008-01-21 13:13 IT進行時
    我現在是先跑起來,之后再逐點優化、調整。
    入門是第一步。  回復  更多評論
      

    # re: Spring2.x與ActiveMQ5.0成功集成的心得(配置篇) 2008-01-30 09:59 yahoo
    把代碼發出來啊  回復  更多評論
      

    主站蜘蛛池模板: 中国一级特黄的片子免费 | 亚洲欧洲精品成人久久奇米网 | **俄罗斯毛片免费| 亚洲人成网站在线观看播放| fc2免费人成为视频| 亚洲第一区精品日韩在线播放| 黄色一级毛片免费看| 亚洲国产精品国产自在在线| 一级白嫩美女毛片免费| 亚洲国产成人精品女人久久久| 人成午夜免费大片在线观看| 久久久久亚洲精品中文字幕| 国产精品美女久久久免费 | 边摸边脱吃奶边高潮视频免费| 国产成人免费全部网站| 国产亚洲综合视频| 久久亚洲AV永久无码精品| baoyu116.永久免费视频| 久久亚洲国产视频| 91久久精品国产免费直播| 亚洲中文字幕一二三四区| 在线视频免费国产成人| 免费人成大片在线观看播放| 中文字幕亚洲日本岛国片| 国产白丝无码免费视频| 亚洲一区二区影视| 国产成人免费a在线视频app| 一个人看的www免费在线视频| 亚洲成在人线av| 免费毛片a在线观看67194| 亚洲精品蜜夜内射| 国产亚洲精品AA片在线观看不加载| 高清一区二区三区免费视频| 亚洲人成图片网站| 亚洲人成无码网WWW| 中文字幕免费在线| 国产亚洲男人的天堂在线观看 | 成人无码区免费视频观看| 一级做a爰片久久毛片免费看| 亚洲国产天堂在线观看| 国产精品久免费的黄网站|