【发布时间】:2013-02-25 03:28:02
【问题描述】:
我有 2 个问题。他们在这里:
有没有办法确定等待的消息数量 在弹簧集成通道中处理,而数量 客户不断增加?
在应用程序上下文中,我希望能够定义 x 个实例 x 和 y 都从通道 p 以编程方式消耗的 bean y 根据负载增加或减少消费者。
spring 2gx 中显示了一个示例,但它使用rabbitmq 来确定负载。
【问题讨论】:
标签: spring integration
我有 2 个问题。他们在这里:
有没有办法确定等待的消息数量 在弹簧集成通道中处理,而数量 客户不断增加?
在应用程序上下文中,我希望能够定义 x 个实例 x 和 y 都从通道 p 以编程方式消耗的 bean y 根据负载增加或减少消费者。
spring 2gx 中显示了一个示例,但它使用rabbitmq 来确定负载。
【问题讨论】:
标签: spring integration
如果你愿意,你也可以通过 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
【讨论】: