Added a handy processingDelay option to the MessageIdList so that a test case and simulate a slow consumer

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@560294 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2007-07-27 16:02:04 +00:00
parent d56ebd842d
commit 9d2e5418fe
1 changed files with 28 additions and 1 deletions

View File

@ -51,7 +51,8 @@ public class MessageIdList extends Assert implements MessageListener {
private boolean verbose; private boolean verbose;
private MessageListener parent; private MessageListener parent;
private long maximumDuration = 15000L; private long maximumDuration = 15000L;
private long processingDelay=0;
private CountDownLatch countDownLatch; private CountDownLatch countDownLatch;
public MessageIdList() { public MessageIdList() {
@ -119,6 +120,12 @@ public class MessageIdList extends Assert implements MessageListener {
if (parent != null) { if (parent != null) {
parent.onMessage(message); parent.onMessage(message);
} }
if( processingDelay > 0 ) {
try {
Thread.sleep(processingDelay);
} catch (InterruptedException e) {
}
}
} }
public int getMessageCount() { public int getMessageCount() {
@ -241,4 +248,24 @@ public class MessageIdList extends Assert implements MessageListener {
this.countDownLatch = countDownLatch; this.countDownLatch = countDownLatch;
} }
/**
* Gets the amount of time the message listener will spend sleeping to
* simulate a processing delay.
*
* @return
*/
public long getProcessingDelay() {
return processingDelay;
}
/**
* Sets the amount of time the message listener will spend sleeping to
* simulate a processing delay.
*
* @param processingDelay
*/
public void setProcessingDelay(long processingDelay) {
this.processingDelay = processingDelay;
}
} }