java - org.apache.activemq.transport.InactivityIOException : Cannot send, channel 已经失败

标签 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% 情况下不会发生这种情况。

最佳答案

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

当类路径中缺少其中一个 jar 时,Apache ActiveMQ 客户端会抛出 InactivityIOException。在我的例子中,它是 hawtbuf-1.11.jar。当我将这个 jar 添加到类路径时,它开始正常工作。

关于java - org.apache.activemq.transport.InactivityIOException : Cannot send, channel 已经失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27113501/

相关文章:

java pdf 打印 NetBeans

java - 如何在运行集成测试时查看 H2 内存数据库?

apache - Apache Camel HTTP组件计时器dockerization

java - 高性能 JMS 消息传递

logging - 使用 Stomp 和 Apache ActiveMQ 作为可靠的系统日志

java - Java中为什么要用反斜杠来代替特殊字符?

java - RabbitMQ 与 Camel

java - InterceptSendToEndpoint不拦截Route中的http请求,使用Camel和Springboot

mysql - 如何防止mysql数据库中出现重复数据

java - 如何将 PDF 转换为文本文件并保留 PDF 的格式?