title: ActiveMQ throttling consumer
body: <p>i want to do a throttling to a consumer of some queue in the activeMQ, in hornetq (of jboss, this is do it with annotations on the definition of the mdb Consumer). I can't find any similar in the documentation of activemq, the closest that i find was this</p>
  
  <pre><code>consumer.recvDelay   0 ms    Pause consumer for recvDelay milliseconds with each message (allows consumer throttling).
  </code></pre>
  
  <p>from: <a href="http://activemq.apache.org/activemq-performance-module-users-manual.html" rel="nofollow noreferrer">http://activemq.apache.org/activemq-performance-module-users-manual.html</a></p>
  
  <p>But there i can't find how i can do it in java.</p>
  
  <p>Thanks in advance,</p>
  
  <p>Regards.</p>
  
  <p>EDIT: Here is the ActiveMQManager code and the consumer code:</p>
  
  <pre><code>public class ActiveMQManager {
  
      private static ActiveMQConnectionFactory CONNECTION_FACTORY;
  
      public static Connection CONNECTION;
  
      public static Session SESSION;
  
      public static Destination TEST_QUEUE;
  
      public static void start() {
          try {
  
              CONNECTION_FACTORY = new ActiveMQConnectionFactory("vm://localhost");
  
              CONNECTION = CONNECTION_FACTORY.createConnection();
              CONNECTION.start();
  
              SESSION = CONNECTION.createSession(false,
                      Session.CLIENT_ACKNOWLEDGE);
  
              TestClient testClient = new TestClient();
  
              TEST_QUEUE = SESSION.createQueue("TEST.QUEUE");
  
              MessageConsumer testConsumer = SESSION.createConsumer(TEST_QUEUE);
              test.setMessageListener(testClient);
  
          } catch (Exception e) {
          }
      }
  
      public static void stop() {
          try {
              // Clean up
              SESSION.close();
              CONNECTION.close();
          } catch (JMSException e) {
              log.error(e);
          }
      }
  }
  </code></pre>
  
  <p>The consumer code is very simple (for this example):</p>
  
  <pre><code>public class TestConsumer implements MessageListener {
  
      @Override
      public void onMessage(Message message) {
          //Do something with the message
      }
  
  }
  </code></pre>