使用ActiveMQ PooledConnectionFactory卸载Blueprint bundle会导致javax.jms.IllegalStateException:Consumer已关闭

时间:2016-05-30 15:42:37

标签: apache-camel activemq apache-karaf blueprint-osgi

我使用Camel(尝试过2.15.2和2.16.3)和activemq-camel(尝试过的5.12.1和5.13.3)组件将我的bundle中的路由连接到外部ActiveMQ服务器。捆绑包部署在Karaf(尝试3.0.5和4.0.5)并通过Blueprint上下文(包含Camel上下文)启动。有问题的包只包含一个amq生成器。

只要没有交换消息,卸载/重新启动捆绑包就没有问题。但是在第一次消息交换之后的任何时候,我在卸载软件包时都会收到javax.jms.IllegalStateException:

2016-05-30 17:12:51,937 | WARN  | V.XACML.REQUEST] | TemporaryQueueReplyManager       | 75 - org.apache.camel.camel-jms -
2.16.3 | ID-Ralfs-MacBook-Pro-local-59456-1464621134397-7-2 | Exception inside the DMLC for Temporary ReplyTo Queue for destination DEV.XACML.REQUEST, refreshing ReplyTo destination javax.jms.IllegalStateException: The Consumer is closed
    at org.apache.activemq.ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:880)[64:org.apache.activemq.activemq-osgi:5.13.3]
    at org.apache.activemq.ActiveMQMessageConsumer.receive(ActiveMQMessageConsumer.java:641)[64:org.apache.activemq.activemq-osgi:5.13.3]
    at org.apache.activemq.jms.pool.PooledMessageConsumer.receive(PooledMessageConsumer.java:67)[64:org.apache.activemq.activemq-osgi:5.13.3]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:430)[106:org.apache.servicemix.bundles.spring-jms:3.2.14.RELEASE_1]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:310)[106:org.apache.servicemix.bundles.spring-jms:3.2.14.RELEASE_1]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)[106:org.apache.servicemix.bundles.spring-jms:3.2.14.RELEASE_1]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1103)[106:org.apache.servicemix.bundles.spring-jms:3.2.14.RELEASE_1]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1095)[106:org.apache.servicemix.bundles.spring-jms:3.2.14.RELEASE_1]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:992)[106:org.apache.servicemix.bundles.spring-jms:3.2.14.RELEASE_1]
    at java.lang.Thread.run(Thread.java:745)[:1.8.0_77]

这会导致无限重试连接回临时队列:

2016-05-30 17:12:51,940 | WARN  | V.XACML.REQUEST] | faultJmsMessageListenerContainer | 106 - org.apache.servicemix.bundles.spring-jms - 3.2.14.RELEASE_1 | ID-Ralfs-MacBook-Pro-local-59456-1464621134397-7-2 | Setup of JMS message listener invoker failed for destination 'temporary' - trying to recover. Cause: The Consumer is closed
2016-05-30 17:12:51,941 | INFO  | V.XACML.REQUEST] | PooledConnection                 | 64 - org.apache.activemq.activemq-osgi - 5.13.3 | ID-Ralfs-MacBook-Pro-local-59456-1464621134397-7-2 | failed to delete Temporary Queue "temp-queue://ID:Ralfs-MacBook-Pro.local-59467-1464621151437-1:2:1" on closing pooled connection: The connection is already closed
2016-05-30 17:12:51,943 | ERROR | V.XACML.REQUEST] | faultJmsMessageListenerContainer | 106 - org.apache.servicemix.bundles.spring-jms - 3.2.14.RELEASE_1 | ID-Ralfs-MacBook-Pro-local-59456-1464621134397-7-2 | Could not refresh JMS Connection for destination 'temporary' - retrying in 5000 ms. Cause: null
[rest of component shutdown logs...]
2016-05-30 17:12:56,944 | ERROR | V.XACML.REQUEST] | faultJmsMessageListenerContainer | 106 - org.apache.servicemix.bundles.spring-jms - 3.2.14.RELEASE_1 |  | Could not refresh JMS Connection for destination 'temporary' - retrying in 5000 ms. Cause: null
2016-05-30 17:13:01,948 | ERROR | V.XACML.REQUEST] | faultJmsMessageListenerContainer | 106 - org.apache.servicemix.bundles.spring-jms - 3.2.14.RELEASE_1 |  | Could not refresh JMS Connection for destination 'temporary' - retrying in 5000 ms. Cause: null
2016-05-30 17:13:06,953 | ERROR | V.XACML.REQUEST] | faultJmsMessageListenerContainer | 106 - org.apache.servicemix.bundles.spring-jms - 3.2.14.RELEASE_1 |  | Could not refresh JMS Connection for destination 'temporary' - retrying in 5000 ms. Cause: null
2016-05-30 17:13:11,956 | ERROR | V.XACML.REQUEST] | faultJmsMessageListenerContainer | 106 - org.apache.servicemix.bundles.spring-jms - 3.2.14.RELEASE_1 |  | Could not refresh JMS Connection for destination 'temporary' - retrying in 5000 ms. Cause: null
[...]

我如何设置我的上下文以支持捆绑包重新启动并仍然使用临时队列进行请求 - 回复消息传递?

我目前的配置如下:

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="${activemq.broker.url} />
    <property name="userName" value="${activemq.user}" />
    <property name="password" value="${activemq.password}" />
    <property name="useAsyncSend" value="true" />
</bean>

<bean id="pooledConnectionFactoryProducer" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
    <property name="maxConnections" value="${activemq.maxconnections}" />
    <property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>

<bean id="jmsConfigProducer" class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="connectionFactory" ref="pooledConnectionFactoryProducer" />
    <property name="deliveryPersistent" value="false" />
    <property name="replyToDeliveryPersistent" value="false" />
    <property name="transacted" value="false" />
</bean>

<bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="configuration" ref="jmsConfigProducer" />
</bean>

0 个答案:

没有答案