From 9d2e5418fe153b2ade3c977045d6c23430ee7ae2 Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Fri, 27 Jul 2007 16:02:04 +0000 Subject: [PATCH] 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 --- .../apache/activemq/util/MessageIdList.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/util/MessageIdList.java b/activemq-core/src/test/java/org/apache/activemq/util/MessageIdList.java index 7328007969..1de9140370 100644 --- a/activemq-core/src/test/java/org/apache/activemq/util/MessageIdList.java +++ b/activemq-core/src/test/java/org/apache/activemq/util/MessageIdList.java @@ -51,7 +51,8 @@ public class MessageIdList extends Assert implements MessageListener { private boolean verbose; private MessageListener parent; private long maximumDuration = 15000L; - + private long processingDelay=0; + private CountDownLatch countDownLatch; public MessageIdList() { @@ -119,6 +120,12 @@ public class MessageIdList extends Assert implements MessageListener { if (parent != null) { parent.onMessage(message); } + if( processingDelay > 0 ) { + try { + Thread.sleep(processingDelay); + } catch (InterruptedException e) { + } + } } public int getMessageCount() { @@ -241,4 +248,24 @@ public class MessageIdList extends Assert implements MessageListener { 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; + } + }