2013-02-25 38 views
0

我有2個問題。在這裏,他們是:春季整合頻道留言數

  1. 有什麼方法來確定等待 在彈簧整合渠道處理的消息的數量,同時 客戶數量不斷沿着時間的增加?

  2. 在應用方面,我希望能夠以限定其中x和y,無論是從信道p消耗,編程 增加或減少基於負載的消費者 豆Y的x的實例。

有一個例子顯示在spring2gx中,但它使用rabbitmq來確定負載。

回答

0
  • 對於1),Spring集成通道就像任何其他bean一樣。假設你使用的是標準的可輪詢的通道,你可以通過名字自動裝配,然後得到的消息數等待:

http://docs.spring.io/spring-integration/api/org/springframework/integration/channel/QueueChannel.html#getQueueSize()

您可能還可以,如果你通過JMX反思這個想。

  • 對於2)......爲了做到這一點,你要對一個對象池的頂部使用AOP代理,再用鐵絲代理到(我認爲是)服務激活。這些屬性可以通過PropertyPlaceholderConfigurer進行外部化。所以,作爲一個例子:

    <bean id="propertyPlaceholder" 
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
        <property name="systemPropertiesMode" value="2" /> 
        <property name="locations" value="classpath:my_config_params.properties" /> 
    </bean> 
    
    <bean id="myBusinessObjectImpl" class="com.mycompany.whatever.impl.MyServiceImpl" 
         scope="prototype" autowire-candidate="false" /> 
    
    <bean id="myBusinessObjPool" class="org.springframework.aop.target.CommonsPoolTargetSource"> 
        <property name="targetBeanName" value="myBusinessObjectImpl" /> 
        <!-- THIS IS THE KEY. myconfig.params.poolsize is the name of the property in the my_config_params.properties above. --> 
        <property name="maxSize" value="${myconfig.params.poolsize}" /> 
    </bean> 
    
    <bean id="myBusinessObject" class="org.springframework.aop.framework.ProxyFactoryBean"> 
        <property name="targetSource" ref="myBusinessObjPool" /> 
    </bean> 
    
    <int:channel id="myInputChannel"> 
        <int:queue size="500" /> 
    </int:channel> 
    
    <int:service-activator inputChannel="myInputChannel" ref="myBusinessObject" method="processMessages"> 
        <int:poller max-messages-per-poll="10" fixed-rate="5000"/> 
    </int:service> 
    

這也使您可以在服務激活狀態。 強制鏈接到對象池功能:

http://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/aop-api.html#aop-ts-pool