org.apache.activemq.transport.InactivityIOException:无法发送,频道已失败

时间:2014-11-24 20:23:49

标签: java apache-camel activemq

我正在使用apache的activemq进行排队。在将内容写入队列时,我们已经开始经常看到以下异常:

Caused by: org.apache.activemq.transport.InactivityIOException: Cannot send, channel has already failed: 
    at org.apache.activemq.transport.AbstractInactivityMonitor.doOnewaySend(AbstractInactivityMonitor.java:282)
    at org.apache.activemq.transport.AbstractInactivityMonitor.oneway(AbstractInactivityMonitor.java:271)
    at org.apache.activemq.transport.TransportFilter.oneway(TransportFilter.java:85)
    at org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:104)
    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:1366)

我无法弄清楚导致这种情况的原因 - 甚至坦率地说,从哪里开始调试导致这种情况的原因。

这是队列设置代码:

    camelContext = new DefaultCamelContext();
    camelContext.setErrorHandlerBuilder(new LoggingErrorHandlerBuilder());
    camelContext.getShutdownStrategy().setTimeout(SHUTDOWN_TIMEOUT_SECONDS);

    routePolicy = new RoutePolicy();
    routePolicy.setCamelContext(camelContext);

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL(queueUri);
    // use a pooled connection factory between the module and the queue
    pooledConnectionFactory = new PooledConnectionFactory(connectionFactory);

    // how many connections should there be in the session pool?
    pooledConnectionFactory.setMaxConnections(this.maxConnections);
    pooledConnectionFactory.setMaximumActiveSessionPerConnection(this.maxActiveSessionPerConnection);
    pooledConnectionFactory.setCreateConnectionOnStartup(true);
    pooledConnectionFactory.setBlockIfSessionPoolIsFull(false);

    JmsConfiguration jmsConfiguration = new JmsConfiguration(pooledConnectionFactory);
    jmsConfiguration.setDeliveryPersistent(false); // do not store a copy of the messages on the queue

    ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent(queueUri);
    activeMQComponent.setConfiguration(jmsConfiguration);
    camelContext.addComponent("activemq", activeMQComponent);
    Component activemq = camelContext.getComponent("activemq");

    // register endpoints for queues and topics
    Endpoint queueEndpoint = activemq.createEndpoint("activemq:queue:polaris.*");
    Endpoint topicEndpoint = activemq.createEndpoint("activemq:topic:polaris.*");
    producerTemplate = camelContext.createProducerTemplate();

    camelContext.start();
    queueEndpoint.start();
    topicEndpoint.start();

就像我说的那样,错误没有提示调试的任何指示,并且在100%的情况下我不能确定我的配置没有正确设置。

3 个答案:

答案 0 :(得分:1)

最近我遇到了同样的问题。我找到了这个https://issues.apache.org/jira/browse/AMQ-6600

Apache ActiveMQ客户端在类路径中缺少其中一个jar时抛出InactivityIOException。就我而言,它是hawtbuf-1.11.jar。当我将这个jar添加到classpath时,它开始工作而没有错误。

答案 1 :(得分:0)

检查是否有非Jms客户端ping您的JMS代理。这可能是外部监控工具,负载平衡工具,如keepalived或其他工具。

答案 2 :(得分:0)

  • 管理端口:61616(默认)
  • 服务端口:8161(默认)

将您的代理 url 端口更改为 61616 并运行

refer this