5

In my server log I can see occasionally exceptions like:

Aug 11, 2015 10:13:34 AM org.apache.activemq.broker.TransportConnection serviceTransportException
WARNING: Transport Connection to: tcp://127.0.0.1:55472 failed: java.io.EOFException

Those do not seem to be actual events or messages send to the queue. They just happen randomly.

This is with ActiveMQ on Tomcat/Tomee

The code that configures ActiveMQ is:

My ActiveMQ configuration is very simple:

<?xml version="1.0" encoding="UTF-8"?>
<tomee>
    <!-- see http://tomee.apache.org/containers-and-resources.html -->

    <!-- activate next line to be able to deploy applications in apps -->
    <!-- <Deployments dir="apps" /> -->

    <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
        BrokerXmlConfig =  broker:(tcp://localhost:61616)
        ServerUrl       =  tcp://localhost:61616
    </Resource>

    <Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
        ResourceAdapter = MyJmsResourceAdapter
    </Resource>

</tomee>

And to define the Queue I have a simple code:

@Resource(name = "myQueue")
private Queue barQueue;

@Resource
private ConnectionFactory connectionFactory;

/**
 * Push Message to Queue
 *
 * @param payload
 * @throws JMSException
 */
private void pushToQueue(Serializable payload) throws JMSException {
    Connection connection = connectionFactory.createConnection();
    connection.start();

    // Create a Session
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    // Create a MessageProducer from the Session to the Topic or Queu
    MessageProducer producer = session.createProducer(barQueue);
    producer.setDeliveryMode(DeliveryMode.PERSISTENT);

    // Create a message
    ObjectMessage message = session.createObjectMessage(payload);

    // Tell the producer to send the message
    producer.send(message);

    connection.close();
}

I can see messages fine in the log.

I just randomly see this EOFException popping up.

And it happens without me adding any messages to the queue.

seba.wagner
  • 3,800
  • 4
  • 28
  • 52
  • EOFException (End of File exception) means that a program has unexpectedly reached the end of a file. There is no good way (as far as I can tell) that we can help you without seeing any of your code. – lacraig2 Aug 10 '15 at 22:28
  • I have added the code that I use to configure the queue and to add messages to the queue as well as the server config that sets up the ActiveMQ Broker. – seba.wagner Aug 10 '15 at 23:02
  • I can also add that I can see this exception usually around 14-15 minutes after the last message was put into the queue. Looks like some sort of time out. But I don't see any message failing to be put on the queue. And the stack trace leads to a class that is part of the framework, so nothing initiated by my code. – seba.wagner Aug 11 '15 at 01:25
  • have the very same problem here for years, no reasonable explanation yet – Leo Sep 10 '15 at 13:42
  • Could you please post a bit more from the stacktrace, e.g. the cause. – SubOptimal Sep 15 '15 at 12:52

2 Answers2

1

This is usually caused by the client not cleaning up connections properly. Calling connection.close() is not complete. Also, the bit about the port number being different than 61616 is the client-specific port number of the port-pair.

The best practice for JMS connection clean up:

} finally {
    if(producer != null) {
        try { producer.close(); } catch (JMSException e) { log.. bad thing }
    }
    if(session != null) {
        try { session.close(); } catch (JMSException e) { log.. bad thing }   
    }
    if(connection != null) {
        try { connection.close(); } catch (JMSException e) { log.. bad thing } 
    }  
    producer = null;
    session = null;
    connection = null;
}
Matt Pavlovich
  • 4,087
  • 1
  • 9
  • 17
0

Your ActiveMQ configuration shows that you are opening a connection to the broker on 61616, but the logged error indicates that the client used port 55472. There must be some other client which is making connections.

avis
  • 11
  • 4