Timeout in ActiveMQ AMQP example code
<p>I'm trying to get started with ActiveMQ and I ran the example code. It boils down to this:</p>

<pre><code>JmsConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:=5672");
Connection connection = factory.createConnection(user, password);
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = session.createQueue("change");
MessageConsumer consumer = session.createConsumer(destination);

while (true) {
    Message msg = consumer.receive();
    «process»
}
</code></pre>

<p><a href="https://github.com/apache/activemq/blob/master/assembly/src/release/examples/amqp/java/src/main/java/example/Listener.java" rel="nofollow">Full code here</a></p>

<p>It works fine, but if I don't send messages for a minute or two I get:</p>

<pre><code>Exception in thread "main" javax.jms.JMSException:
Transport closed due to the peer exceeding our requested idle-timeout
</code></pre>

<p>I don't know how often I expect to get messages (could be hundreds a second, could be one a day).</p>

<ol>
<li><p>Is there some configuration option that I need to set so there is never a time-out?</p></li>
<li><p>What's the right way to write a client? Is there a good reason the default has a timeout that means I shouldn't use this method?</p></li>
</ol>

<p>Blocking polling like this is fine for me. </p>

<p>I'm using ActiveMQ 5.11.2. I'm running the server with <code>activemq console</code> and using whatever default configuration ships.</p>