title: Unable to get ActiveMQ to dequeue
body: <p>There might be a stupid simple answer to this, but I'm trying to use ActiveMQ to pass messages between producers and consumers.  I will have many producers and many consumers, but I want each message to be delivered only once among the consumers.  This would seem to mean that I cannot use Topics, since they would deliver messages to all consumers who are listening, and I want only one Consumer to receive each message.</p>
  
  <p>My problem is that I am able to receive messages, but the messages are not dequeued.  So if I restart my consumer process, all of the messages are reprocessed.  <a href="https://stackoverflow.com/questions/1839444/activemq-how-to-dequeue-older-messages">This answer</a> seems pertinent but does not seem to apply since I can't create durable queue consumers, only durable topic consumers (unless I'm missing something in the API docs).  </p>
  
  <p>My code is as follows.</p>
  
  <pre><code>TopicConnectionFactory factory = new ActiveMQConnectionFactory(props.getProperty("mq.url"));
  Connection conn  = factory.createConnection();
  Session session = conn.createSession(true, Session.CLIENT_ACKNOWLEDGE);
  Queue queue = session.createQueue(props.getProperty("mq.source_queue"));
  conn.start();
  MessageConsumer consumer = session.createConsumer(queue);
  </code></pre>
  
  <p>Then later on</p>
  
  <pre><code>Message msg = consumer.receive();
  msg.acknowledge();
  if (!(msg instanceof TextMessage)) continue;
  String msgStr = ((TextMessage)msg).getText();
  </code></pre>
  
  <p>This is my current code.  I have tried with Session.AUTO_ACKNOWLEDGE and without msg.acknowledge().  Any working permutation of this code seems to retrieve the messages, but when I restart my consumer, all of the messages get received again, even if they have been received prior to the restart.</p>