我希望做一個限制在ActiveMQ的一些隊列的消費者,在hornetq(JBoss的,這是在MDB消費者的定義註釋做)。我無法找到的ActiveMQ文檔中的任何類似的,我找到最接近的是這ActiveMQ的節流消費者
consumer.recvDelay 0 ms Pause consumer for recvDelay milliseconds with each message (allows consumer throttling).
從
:http://activemq.apache.org/activemq-performance-module-users-manual.html
但我找不到我怎麼可以在java中做到這一點。
在此先感謝,
問候。
編輯:這裏是ActiveMQManager碼和消費者的代碼:
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);
}
}
}
消費者代碼很簡單(在這個例子中):
public class TestConsumer implements MessageListener {
@Override
public void onMessage(Message message) {
//Do something with the message
}
}
您可以發佈消費者代碼/配置嗎? –
好吧,我會將它添加到問題中。 –