如何在弹簧集成中使用AMQ PooledConnectionFactory?

时间:2012-11-29 12:07:27

标签: spring jms activemq spring-integration

我正在使用与spring Integration 2.1.3和spring 3.0.5集成的activemq 3.7和activemq pool 3.7库。当我试图像这样定义connectionFactory时,我得到了下面的例外

<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <property name="targetConnectionFactory">
        <bean class="org.apache.activemq.pool.PooledConnectionFactory"
            destroy-method="stop">
            <property name="connectionFactory">
                <bean class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
                    <constructor-arg name="brokerURL" value="${jms.broker.url}" />
                </bean>
            </property>
        </bean>
    </property>
    <property name="sessionCacheSize" value="10" />
    <property name="cacheProducers" value="false" />
</bean>

以下是例外:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory' defined in class path resource 
[META-INF/integration-context.xml]: 
Cannot create inner bean 'org.apache.activemq.pool.PooledConnectionFactory#1445748' 
of type [org.apache.activemq.pool.PooledConnectionFactory] 
while setting bean property 'targetConnectionFactory'; nested exception is 
org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.apache.activemq.pool.PooledConnectionFactory#1445748' 
defined in class path resource [META-INF/integration-context.xml]: 
Initialization of bean failed; 
nested exception is java.lang.reflect.MalformedParameterizedTypeException

如果我使用ActiveMQConnectionFactory而不是PooledConnectionFactory,一切都部署得很好但我有性能我有性能问题。

2 个答案:

答案 0 :(得分:0)

首先:你能展示堆栈跟踪的其余部分以及你的“jms.broker.url”属性的值吗?

第二:如果你用Spring的“缓存”CF包装,真的没有必要使用“混合”CF

答案 1 :(得分:0)

Spring使用无界通配符方法抛出异常:

public ObjectPoolFactory<?> getPoolFactory() {
    return null;
}

但是还没有找到解决方案。