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

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

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

    posts - 33,  comments - 70,  trackbacks - 0

    一:續一,說明一的可使用性。

    <amq:queue id="destination.report"  physicalName="active.jms.report"/>
        
    <amq:queue id="destination.point"  physicalName="active.jms.point"/>

    queue : 隊列的名字 for 制造者.

    感覺org.springframework.jms.listener.DefaultMessageListenerContainer 做的不好,如果destination property能做一個可包含多個隊列,并且有選擇性的messageListener就好了,這樣就避免下面的監聽的尷尬了。呵呵
    <!--  listener container,MDP無需實現接口 -->
        
    <bean id="fluxPerhourListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">        
            
    <property name="connectionFactory" ref="jmsConnectionFactory"/>
            
    <property name="destination" ref="destination.fluxPerhour"/>
            
    <property name="messageListener" ref="messageListener"/>
        
    </bean>
        
    <bean id="fluxPerDayListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">        
            
    <property name="connectionFactory" ref="jmsConnectionFactory"/>
            
    <property name="destination" ref="destination.fluxPerday"/>
            
    <property name="messageListener" ref="messageListener"/>
        
    </bean>

    <bean id="reportPerdayProducer" class="com.jms.ReportPerdayProducer">
            
    <property name="template" ref="jmsTemplate"/>
            
    <property name="destination" ref="destination.report"/>
        
    </bean>
        
    <bean id="pointProducer" class="com.jms.PointProducer">
            
    <property name="template" ref="jmsTemplate"/>
            
    <property name="destination" ref="destination.point"/>
        
    </bean>

    producer不能重用,因為send到不同destination,所有沒辦法重用。如果能對producer做一個默認統一的封裝就好了. 但是DefaultProducer.那么應該注意隊列線程安全方面,目前沒有什么好的想法,就采用通用一些的辦法,不過xml和代碼稍多一些.


    然后就用到 前面文章一 里面的內容了,非常簡便。
    <!--  Message Driven POJO (MDP) -->
        
    <bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
    <!--  may be other method -->
            
    <constructor-arg>
                
    <bean class="com..jms.MessageConsumerAdapter" >
                    
    <!--業務接口/業務門面-->
                    
    <property name="transfersManager" ref="transfersManager"/>                
                
    </bean>            
            
    </constructor-arg>
            
    <!--  may be other method -->
            
    <property name="defaultListenerMethod" value="receive"/>
            
    <!-- custom MessageConverter define -->
            
    <property name="messageConverter" ref="messageConverter"/>
        
    </bean>    
    <!--  Holder Message converter  -->
        
    <bean id="messageConverter" class="com.jms.CoverterHolder">
            
    <property name="defaultMessageConverter">
                
    <bean class="com.jms.DefaultMessageConverter"/>
            
    </property>
        
    </bean>


    <!--  Spring JmsTemplate config -->
        
    <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="jmsConnectionFactory"/>
                
    </bean>
            
    </property>
            
    <property name="messageConverter" ref="messageConverter"/>
        
    </bean>
     


    二.單元測試有時加載 activemq的問題
    1.這個可能和spring版本有關系,請采用比較穩定的版本。例如apache-activemq官方包里面提供的.
    2.選擇 xml解析的問題,例如
    public abstract class SpringManagerTestCase extends
            AbstractTransactionalDataSourceSpringContextTests 
    {

        
    public SpringManagerTestCase()
        
    {
            System.setProperty(
    "javax.xml.parsers.DocumentBuilderFactory""org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
            System.setProperty(
    "javax.xml.parsers.SAXParserFactory""org.apache.xerces.jaxp.SAXParserFactoryImpl");
            System.setProperty(
    "javax.xml.transform.TransformerFactory""org.apache.xalan.processor.TransformerFactoryImpl");
            
            setDependencyCheck(
    false);
            setDefaultRollback(
    false);
        }

        
    /**
         * 配置Spring的配置文件的方法。
         * 
    @see org.springframework.test.AbstractDependencyInjectionSpringContextTests#getConfigLocations()
         
    */

        
    protected String[] getConfigLocations() {
            
    return new String[] {"classpath:applicationContext-activemq-embedded.xml"};
        }


    }


    三.為特殊的應用服務器,如resin ,也要選擇特定的xml解析器
    在web.xml中配置增加
    <web-app>
      
    <!--
          In order to be able to compatiable with Resin 2.1.x and 3.0.x,
          both XML and XSLT have to be replaced.
          If only xalan is included, Resin 2.1.x will fail but not 3.0.x.
          Therefore the best way is to use the compatiable version of the
          XML parser ans XSLT.
           - Please refere to the following link for more detailed information.
           - http://www.caucho.com/resin-3.0/xml/jaxp.xtp
      
    -->
      
    <!-- xml -->
      
    <system-property javax.xml.parsers.DocumentBuilderFactory=
                   "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"
    />
      
    <system-property javax.xml.parsers.SAXParserFactory=
                   "org.apache.xerces.jaxp.SAXParserFactoryImpl"
    />
      
    <!--  xslt -->
      
    <system-property javax.xml.transform.TransformerFactory=
                   "org.apache.xalan.processor.TransformerFactoryImpl"
    />


    </web-app>



    以上的以全部在實施中測試通過并且運行。大家可以方向使用和理解。如有疑問,相互交流.
    posted on 2007-04-05 16:55 地獄男爵(hellboys) 閱讀(2822) 評論(0)  編輯  收藏 所屬分類: 編程語言(c/c++ java python sql ......)
    <2007年4月>
    25262728293031
    1234567
    891011121314
    15161718192021
    22232425262728
    293012345

    常用鏈接

    隨筆分類

    隨筆檔案

    文章檔案

    相冊

    連接

    最新隨筆

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲国产高清国产拍精品| 亚洲VA中文字幕不卡无码| 亚洲免费二区三区| 免费视频爱爱太爽了| 亚洲日韩中文字幕| 亚洲美女视频免费| 亚洲最新中文字幕| 在线a级毛片免费视频| 2020国产精品亚洲综合网| 成人免费午夜无码视频| 亚洲永久网址在线观看| 午夜一级免费视频| 全部在线播放免费毛片| 国产精品亚洲w码日韩中文| a一级爱做片免费| 国产AV无码专区亚洲AV毛网站 | 瑟瑟网站免费网站入口| 免费大香伊蕉在人线国产| 人妻仑刮八A级毛片免费看| 久久精品亚洲乱码伦伦中文| 国产一级一毛免费黄片| 久久久久亚洲AV无码专区首| xxxxx免费视频| 亚洲6080yy久久无码产自国产| 日本久久久免费高清| 久久久久国色AV免费观看| 日本亚洲成高清一区二区三区| 毛片无码免费无码播放| 亚洲一区欧洲一区| 亚洲精品国精品久久99热| 国内永久免费crm系统z在线 | 亚洲娇小性xxxx色| 亚洲av无码成人精品区| 九九美女网站免费| 亚洲色大成WWW亚洲女子| 亚洲国模精品一区| 亚州免费一级毛片| 曰批全过程免费视频免费看| 亚洲成人精品久久| 在线jyzzjyzz免费视频| 十八禁在线观看视频播放免费|