activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r439804 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/region/ test/java/org/apache/activemq/
Date Sun, 03 Sep 2006 17:09:51 GMT
Author: chirino
Date: Sun Sep  3 10:09:51 2006
New Revision: 439804

URL: http://svn.apache.org/viewvc?view=rev&rev=439804
Log:
Patch applied from Vadim: https://issues.apache.org/activemq/browse/AMQ-855

Added:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/NullMessageReference.java
      - copied, changed from r439442, incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/EndOfBrowseMarkerQueueMessageReference.java
Removed:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/EndOfBrowseMarkerQueueMessageReference.java
Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/QueueMessageReference.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java

Copied: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/NullMessageReference.java
(from r439442, incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/EndOfBrowseMarkerQueueMessageReference.java)
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/NullMessageReference.java?view=diff&rev=439804&p1=incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/EndOfBrowseMarkerQueueMessageReference.java&r1=439442&p2=incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/NullMessageReference.java&r2=439804
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/EndOfBrowseMarkerQueueMessageReference.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/NullMessageReference.java
Sun Sep  3 10:09:51 2006
@@ -27,7 +27,7 @@
 /**
  * Only used by the {@link QueueMessageReference#NULL_MESSAGE} 
  */
-final class EndOfBrowseMarkerQueueMessageReference implements
+final class NullMessageReference implements
 		QueueMessageReference {
 
 	private ActiveMQMessage message = new ActiveMQMessage();
@@ -50,7 +50,7 @@
 	}
 
 	public boolean lock(LockOwner subscription) {
-		throw new RuntimeException("not implemented");
+		return true;
 	}
 
 	public void setAcked(boolean b) {
@@ -58,7 +58,6 @@
 	}
 
 	public void unlock() {
-		throw new RuntimeException("not implemented");
 	}
 
 	public int decrementReferenceCount() {
@@ -70,11 +69,11 @@
 	}
 
 	public String getGroupID() {
-		throw new RuntimeException("not implemented");
+		return null;
 	}
 
 	public int getGroupSequence() {
-		throw new RuntimeException("not implemented");
+		return 0;
 	}
 
 	public Message getMessage() throws IOException {

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/QueueMessageReference.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/QueueMessageReference.java?view=diff&rev=439804&r1=439803&r2=439804
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/QueueMessageReference.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/QueueMessageReference.java
Sun Sep  3 10:09:51 2006
@@ -25,7 +25,7 @@
  */
 public interface QueueMessageReference extends MessageReference {
 
-    public static final QueueMessageReference NULL_MESSAGE = new EndOfBrowseMarkerQueueMessageReference();
+    public static final QueueMessageReference NULL_MESSAGE = new NullMessageReference();
 
     public boolean isAcked();
     

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java?view=diff&rev=439804&r1=439803&r2=439804
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
Sun Sep  3 10:09:51 2006
@@ -21,14 +21,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
+import javax.jms.*;
 
 /**
  * 
@@ -60,11 +53,36 @@
 
         MessageProducer producer = session.createProducer(queue);
         producer.send(session.createTextMessage("Hello World!"));
-        
+
         // now lets receive it
         MessageConsumer consumer = session.createConsumer(queue);
         Message answer = consumer.receive(5000);
         assertNotNull("Should have received a message!", answer);
+        // check if method will return at all and will return a null
+        answer = consumer.receive(1000);
+        assertNull("Should have not received a message!", answer);
+        answer = consumer.receiveNoWait();
+        assertNull("Should have not received a message!", answer);
+    }
+
+    public void testIdleConsumer() throws Exception {
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        MessageProducer producer = session.createProducer(queue);
+        producer.send(session.createTextMessage("Msg1"));
+        producer.send(session.createTextMessage("Msg2"));
+
+        // now lets receive it
+        MessageConsumer consumer = session.createConsumer(queue);
+        //noinspection UNUSED_SYMBOL
+        MessageConsumer idleConsumer = session.createConsumer(queue);
+        TextMessage answer = (TextMessage) consumer.receive(5000);
+        assertEquals("Should have received a message!", answer.getText(), "Msg1");
+        // this call would return null if prefetchSize > 0
+        answer = (TextMessage) consumer.receive(5000);
+        assertEquals("Should have not received a message!", answer.getText(), "Msg2");
+        answer = (TextMessage) consumer.receiveNoWait();
+        assertNull("Should have not received a message!", answer);
     }
 
     protected void setUp() throws Exception {



Mime
View raw message