[Jboss-cvs] JBoss Messaging SVN: r1202 - in trunk: src/main/org/jboss/jms/client/remoting tests/src/org/jboss/test/messaging/jms
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Aug 6 14:19:53 EDT 2006
Author: ovidiu.feodorov at jboss.com
Date: 2006-08-06 14:19:50 -0400 (Sun, 06 Aug 2006)
New Revision: 1202
Modified:
trunk/src/main/org/jboss/jms/client/remoting/MessageCallbackHandler.java
trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
Log:
minor refactoring
Modified: trunk/src/main/org/jboss/jms/client/remoting/MessageCallbackHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/MessageCallbackHandler.java 2006-08-05 08:33:31 UTC (rev 1201)
+++ trunk/src/main/org/jboss/jms/client/remoting/MessageCallbackHandler.java 2006-08-06 18:19:50 UTC (rev 1202)
@@ -98,7 +98,7 @@
if (ackMode == Session.AUTO_ACKNOWLEDGE || ackMode == Session.DUPS_OK_ACKNOWLEDGE)
{
- //We redeliver at certain number of times
+ // We redeliver at certain number of times
if (tries < MAX_REDELIVERIES)
{
m.setJMSRedelivered(true);
@@ -380,7 +380,8 @@
if (closed)
{
- //If consumer is closed or closing calling receive returns null
+ // If consumer is closed or closing calling receive returns null
+ if (trace) { log.trace(this + " closed, returning null"); }
return null;
}
@@ -399,7 +400,7 @@
{
if (timeout == 0)
{
- if (trace) { log.trace("receive with no timeout"); }
+ if (trace) { log.trace(this + ": receive, no timeout"); }
m = getMessage(0);
@@ -411,26 +412,26 @@
else if (timeout == -1)
{
//ReceiveNoWait
- if (trace) { log.trace("receive noWait"); }
+ if (trace) { log.trace(this + ": receive, noWait"); }
m = getMessage(-1);
if (m == null)
{
- if (trace) { log.trace("no message available"); }
+ if (trace) { log.trace(this + ": no message available"); }
return null;
}
}
else
{
- if (trace) { log.trace("receive timeout " + timeout + " ms, blocking poll on queue"); }
+ if (trace) { log.trace(this + ": receive, timeout " + timeout + " ms, blocking poll on queue"); }
m = getMessage(timeout);
if (m == null)
{
// timeout expired
- if (trace) { log.trace(timeout + " ms timeout expired"); }
+ if (trace) { log.trace(this + ": " + timeout + " ms timeout expired"); }
return null;
}
@@ -514,7 +515,7 @@
{
long start = System.currentTimeMillis();
- //Wait for last message to arrive
+ // Wait for last message to arrive
lock.wait(waitTime);
long waited = System.currentTimeMillis() - start;
@@ -522,7 +523,6 @@
if (waited < waitTime)
{
waitTime = waitTime - waited;
-
return waitTime;
}
else
@@ -543,50 +543,46 @@
{
if (timeout == 0)
{
- // Wait for ever potentially
+ // wait for ever potentially
while (!closed && buffer.isEmpty())
{
- mainLock.wait();
+ if (trace) { log.trace(this + " waiting on main lock, no timeout"); }
+
+ mainLock.wait();
+
+ if (trace) { log.trace(this + " done waiting on main lock"); }
}
}
else
{
- // Wait with timeout
+ // wait with timeout
long toWait = timeout;
while (!closed && buffer.isEmpty() && toWait > 0)
{
- if (trace) { log.trace("Waiting on lock"); }
+ if (trace) { log.trace(this + " waiting on main lock, timeout " + toWait + " ms"); }
+
toWait = waitOnLock(mainLock, toWait);
- if (trace) { log.trace("Done waiting on lock, empty?" + buffer.isEmpty()); }
+
+ if (trace) { log.trace(this + " done waiting on lock, buffer is " + (buffer.isEmpty() ? "" : "NOT ") + "empty"); }
}
}
}
catch (InterruptedException e)
{
+ if (trace) { log.trace("InterruptedException, " + this + ".getMessage() returning null"); }
return null;
}
}
+
+ MessageProxy m = null;
- if (closed)
+ if (!closed && !buffer.isEmpty())
{
- return null;
- }
-
- MessageProxy m = null;
-
- if (!buffer.isEmpty())
- {
m = (MessageProxy)buffer.removeFirst();
-
- if (trace) { log.trace("got " + m + " from buffer"); }
-
}
- else
- {
- m = null;
- }
-
+
+ if (trace) { log.trace("InterruptedException, " + this + ".getMessage() returning " + m); }
return m;
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java 2006-08-05 08:33:31 UTC (rev 1201)
+++ trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java 2006-08-06 18:19:50 UTC (rev 1202)
@@ -2495,6 +2495,8 @@
sess2.unsubscribe("mySubscription1");
+ log.debug("unsubscribed 'mySubscription1'");
+
conn2.close();
Connection conn3 = cf.createConnection();
@@ -2517,10 +2519,13 @@
assertEquals(NUM_MESSAGES, count);
+ log.debug("received " + NUM_MESSAGES + " messages");
+
MessageConsumer durable4 = sess3.createDurableSubscriber(topic, "mySubscription1");
Message m = durable4.receive(1000);
assertNull(m);
+
}
finally
{
More information about the jboss-cvs-commits
mailing list