ActiveMQ FailoverTransport发生意外故障

时间:2014-02-12 16:40:32

标签: java jms apache-camel activemq failover

我有一个(相当)复杂的Java应用程序,它使用Camel(2.11.0)和ActiveMQ(5.8.0)在Camel路由和各种ActiveMQ队列之间发送消息。我正在使用的Camel-ActiveMQ端点定义了故障转移,如下所示:

failover:(tcp://myBroker01.example.com:61616)?jms.prefetchPolicy.queuePrefetch=1&randomize=false&maxReconnectDelay=250

你会注意到我只定义了1个经纪人;现在我只有1个代理(因此这种方式取消了故障转移传输的有用性),但在此之后我可能会有几个代理作为此故障转移URI的一部分。

当我运行我的应用时,我在应用日志中看到以下错误:

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: <com.me.myapp.model.WidgetVO>
    ...middle portion of stack trace omitted for brevity; probably irrelevant
Caused by: javax.jms.JMSException: Unexpected failure.
    at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
    at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1409)
    at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1496)
    at org.apache.activemq.ActiveMQConnection.createSession(ActiveMQConnection.java:325)
    at org.apache.activemq.pool.ConnectionPool$2.makeObject(ConnectionPool.java:105)
    at org.apache.activemq.pool.ConnectionPool$2.makeObject(ConnectionPool.java:90)
    at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1220)
    at org.apache.activemq.pool.ConnectionPool.createSession(ConnectionPool.java:142)
    at org.apache.activemq.pool.PooledConnection.createSession(PooledConnection.java:174)
    at org.springframework.jms.support.JmsAccessor.createSession(JmsAccessor.java:196)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:457)
    ... 76 more
Caused by: java.io.IOException: Unexpected failure.
    at org.apache.activemq.transport.failover.FailoverTransport.oneway(FailoverTransport.java:620)
    at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68)
    at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:81)
    at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:86)
    at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1380)
    ... 85 more

因此,看起来Camel正在正确读取我的故障转移传输配置,并尝试异步发送(oneway(...))序列化WidgetVO消息到我的队列。我搜索了GrepCode for line 620 of FailoverTransport,这里是抛出异常的代码块:

if (transport == null) {
    // Previous loop may have exited due to use being
    // disposed.
    if (disposed) {
        error = new IOException("Transport disposed.");
    } else if (connectionFailure != null) {
        error = connectionFailure;
    } else if (timedout == true) {
        error = new IOException("Failover timeout of " + timeout + " ms reached.");
    } else {
        error = new IOException("Unexpected failure.");
    }

    break;
}

所以Transport为NULL,但是消息没有被标记为处理,也没有连接失败,我们与代理的连接也没有超时。

这对任何人都有意义吗?谁能给我一些关于如何开始调试的指示?如果需要,我很乐意发布更多代码。

更新:这是我在应用程序日志之前中看到的另一条警告消息:

07:53:00,306 WARN  [DefaultJmsMessageListenerContainer] Rejecting received message because of
the listener container having been stopped in the meantime: ActiveMQTextMessage {commandId
= 7, responseRequired = true, messageId = ID:<myserver.example.com>, originalDestination = null,
originalTransactionId = null, producerId = ID:<myserver.example.com>, destination = queue://myQueue,
transactionId = null, expiration = 0, timestamp = 1392295980294, arrival = 0,
brokerInTime = 1392295980297, brokerOutTime = 1392295980298, correlationId = null, replyTo = null,
persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0,
targetConsumerId = null, compressed = false, userID = null, content = null,
marshalledProperties = org.apache.activemq.util.ByteSequence@2d0b20f5, dataStructure = null,
redeliveryCounter = 0, size = 0, properties = {breadcrumbId=ID-<myserver.example.com>},
readOnlyProperties = true, readOnlyBody = true, droppable = false, text = <com.me.myapp.WidgetVO>
 ...WidgetVO>}

出于安全考虑,我显然必须将所有服务器名称更改为<myserver.example.com>。我认为有趣的是transactionId是NULL ...

0 个答案:

没有答案