jms - Camel jms 到外部 activeMQ 的请求-回复给出 javax.jms.InvalidDestinationException : Cannot publish to a deleted Destination:

标签 jms activemq apache-camel connection-pooling jmstemplate

我们有第三方应用程序,可以对camel cxfrs端点进行restful调用,然后将其路由到外部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 配置:

<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 路由器类: //重新路由 from("cxfrs:/rr?resourceClasses=x.y.z.route.RerouteResource") .setExchangePattern(ExchangePattern.InOut) .process(新的重新路由处理器()) .to("activemq:queue: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。即便如此,问题仍然存在。

我真的很困惑,不知道如何解决这个问题。有人可以指出可能出了什么问题吗?

谢谢。

最佳答案

我想知道是否是因为处理另一端的 JMS 消息花费了太长时间,然后 ActiveMQ 的非事件监视器删除了临时目标,因为它的非事件时间超过 30 秒。 http://activemq.apache.org/activemq-inactivitymonitor.html

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

另一种选择是使用固定队列作为回复队列而不是临时队列。

关于jms - Camel jms 到外部 activeMQ 的请求-回复给出 javax.jms.InvalidDestinationException : Cannot publish to a deleted Destination:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16158192/

相关文章:

java - JMeter - 在变量/属性中存储/更新 HashMap 对象

java - 连接到远程 JMX 代理 ActiveMQ Artemis 时出错

java - ActiveMQ SSL 连接 keystore 和信任库类型

activemq - 仅当从属在故障转移中变为事件状态时,如何在从属 ActiveMQ 上启动 Camel 路由?

java - 如何在 Camel 路由上模拟 Kafka Consumer 端点?

http - Apache Camel 作为 HTTP 代理 : how route to URL with parameters

grails - 使用 ESB/MessageBroker 或 Grails 处理 SOAP 调用?

java - 关于聚合消息

java - ActiveMQ 生产者从 PostgreSQL 表内的内容发送消息

java - 服务器重启后将消息保留在主题中