使用request-reply将Camel jms发送到外部activeMQ会产生javax.jms.InvalidDestinationException:无法发布到已删除的Destination:

时间:2013-04-22 23:05:39

标签: jms activemq apache-camel connection-pooling jmstemplate

我们有第三方应用程序对camel cxfrs端点进行了重新调用,然后将其路由到外部activeMQ。有些应用程序使用这些JMS消息并提供XML响应。这都是使用camel InOut exchangePattern同步完成的。该架构非常简单直接。我们使用的是activeMQ 5.5.0-fuse,camel-jms 2.8.x和activemq-pool 5.6。

使用此配置,我们会在随机时间看到此异常:

 javax.jms.InvalidDestinationException: Cannot publish to a deleted Destination: temp-  queue://ID:testserver-37266-1366126830205-0:0:1
    at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1696)
    at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:231)
    at org.apache.activemq.pool.PooledProducer.send(PooledProducer.java:74)
    at org.apache.activemq.pool.PooledProducer.send(PooledProducer.java:55)

当发生这种情况时,服务器就会停止运行,我们的服务都没有响应,直到我们重新启动activeMQ,tomcat和所有其他服务。

camel config:

<import resource="classpath:META-INF/cxf/cxf.xml"/>

 <bean id="routeBuilder" class="gov.nasa.arc.tmi.route.TMIServiceRoute"/>

 <bean id="jaxbProvider" class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
     <property name="marshallerProperties" ref="propertiesMap"/>
    </bean>
    <util:map id="propertiesMap">
        <entry key="jaxb.formatted.output">
           <value type="java.lang.Boolean">true</value>
        </entry>
    </util:map>

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <routeBuilder ref="routeBuilder"/>
</camelContext>


<bean id="activemq" 
  class="org.apache.activemq.camel.component.ActiveMQComponent">
  <property name="brokerURL" value="tcp://localhost:61616"/>

Camel Router类:    //重路由         从( “cxfrs:?/ RR resourceClasses = x.y.z.route.RerouteResource”)         .setExchangePattern(ExchangePattern.InOut)         .process(new RerouteProcessor())         。要( “ActiveMQ的:队列:x.y.z.tmi.request”);

以下是侦听队列的应用程序的spring配置:x.y.z.tmi.request使用JMS消息:

<context:annotation-config/>
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL">
       <value>tcp://localhost:61616? wireFormat.maxInactivityDurationInitalDelay=30000</value>
    </property>
</bean> 

<bean id="pooledConnectionFactory" 
   class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
   <property name="maxConnections" value="8" />
   <property name="connectionFactory" ref="connectionFactory" />
</bean>

<bean id="destination" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="gov.nasa.arc.tmi.request"/>
</bean>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">    
    <property name="connectionFactory" ref="pooledConnectionFactory"/>
    <property name="defaultDestination" ref="destination" />
</bean> 

<jms:listener-container  connection-factory="pooledConnectionFactory" concurrency="10">
 <jms:listener  destination="gov.nasa.arc.tmi.request" ref="tmiQueryListener" />

谷歌搜索后,我遇到了这些错误:

https://issues.apache.org/jira/browse/CAMEL-6229 https://issues.apache.org/jira/browse/AMQ-3457

基于这些,我们升级到了camel 2.10.4,activeMq 5.7和activemq-pool 5.7。即便如此,问题仍然存在。

我真的被卡住了,不知道如何解决这个问题。有人可以指出可能出现的问题吗?

感谢。

1 个答案:

答案 0 :(得分:2)

我想知道是否因为处理另一方的JMS消息需要太长时间,然后ActiveMQ的非活动监视器删除临时目标,因为它对于&gt;处于非活动状态。 30秒。 http://activemq.apache.org/activemq-inactivitymonitor.html

也许尝试将超时设置为更高的值,或者禁用它。

另一种选择是使用固定队列代替临时队列。