Denise
Denise

Reputation: 2005

org.apache.activemq.transport.InactivityIOException: Cannot send, channel has already failed

I am using apache's activemq for queueing. We have started to see the following exception very often when writing things to the queue:

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)

I can't figure out what could be causing this-- or even, frankly, where to start debugging what is causing this.

Here is the queue set up code:

    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();

Like I said, the error doesn't suggest any directions for debugging, and it doesn't happen in 100% of cases where I can be sure my configuration is not set up correctly.

Upvotes: 11

Views: 25740

Answers (4)

chris
chris

Reputation: 1785

I am using Artemis 2.33.0 and wrote an app that produces text messages. These are the minimum jar's i needed for this to work:

  • jakarta.jms-api-2.0.3.jar
  • activemq-client-5.18.3.jar
  • slf4j-api-2.0.11.jar
  • hawtbuf-1.11.jar

I took the jars from the lib folder of the artemis installation. After removing slf4j-api-2.0.11.jar the app compiles but throws an exception at runtime. After removing hawtbuf-1.11.jar the app compiles but throws an exception at runtime: "...javax.jms.JMSException: Cannot send, channel has already failed: tcp://127.0.0.1:61616..."

Here is the code:

package firstartemis;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.NamingException;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;

public class ArtemisProducer {

private static final Logger LOG = Logger.getLogger(ArtemisProducer.class.getName());

private void go() throws NamingException, JMSException {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61616");
    
    ActiveMQConnection connection = (org.apache.activemq.ActiveMQConnection) connectionFactory.createConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    ActiveMQQueue destination = (org.apache.activemq.command.ActiveMQQueue) session.createQueue("qname");
    MessageProducer producer = (MessageProducer) session.createProducer(destination);
    producer.setDeliveryMode(DeliveryMode.PERSISTENT);

    for (int i = 0; i < 120; i++) {
        String text = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(Calendar.getInstance().getTime());
        TextMessage message = (TextMessage) session.createTextMessage(text);
        producer.send(message);
        LOG.info("mesage sent");
        try {
            Thread.sleep(500);
        } catch (InterruptedException ex) {
            LOG.info("interrupted.");
        }
    }
    
    session.close();
    connection.close();
}

public static void main(String[] args) {
    try {
        new ArtemisProducer().go();
    } catch (Exception ex) {
        Logger.getLogger(ArtemisProducer.class.getName()).log(Level.SEVERE, null, ex);
    }
}

}

Upvotes: 0

Nitin
Nitin

Reputation: 119

  • management port: 61616 (default)
  • service port : 8161(default)

change your broker url port to 61616 and run

refer this

Upvotes: 4

Mykola Yashchenko
Mykola Yashchenko

Reputation: 5361

Recently I ran into the same problem. I found this https://issues.apache.org/jira/browse/AMQ-6600

Apache ActiveMQ client throws InactivityIOException when one of the jars is missing in classpath. In my case it was hawtbuf-1.11.jar. When I added this jar to classpath it started to work without errors.

Upvotes: 3

Peter Keller
Peter Keller

Reputation: 7636

Check, if there is a non-Jms client pinging your JMS broker. This may be an external monitoring tool, a load balancing tool such as keepalived, or another one.

Upvotes: 1

Related Questions