qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r760952 - in /qpid/trunk/qpid/java/broker/src: main/java/org/apache/qpid/server/queue/MessageFactory.java test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java
Date Wed, 01 Apr 2009 16:26:50 GMT
Author: ritchiem
Date: Wed Apr  1 16:26:50 2009
New Revision: 760952

URL: http://svn.apache.org/viewvc?rev=760952&view=rev
Log:
QPID-1783 : Relax MessageFactory to allow out of order recovery
Relax MessageFactory to allow out of order. Updated test

Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/MessageFactory.java
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/MessageFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/MessageFactory.java?rev=760952&r1=760951&r2=760952&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/MessageFactory.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/MessageFactory.java
Wed Apr  1 16:26:50 2009
@@ -85,17 +85,13 @@
             throw new RuntimeException("Unable to create message by ID when not recovering");
         }
 
-        long currentID = _messageId.get();
-        if (messageId <= currentID)
+        if (messageId < 0L)
         {
-            throw new RuntimeException("Message IDs can only increase current id is:"
-                                       + currentID + ". Requested:" + messageId);
-        }
-        else
-        {
-            _messageId.set(messageId);
+            throw new RuntimeException("Message IDs can only be positive. Requested:" + messageId);
         }
 
+        _messageId.set((int)Math.max(messageId, _messageId.get()));
+
         return createNextMessage(messageId, transactionLog, true);
     }
 

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java?rev=760952&r1=760951&r2=760952&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java
(original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MessageFactoryRecoveryTest.java
Wed Apr  1 16:26:50 2009
@@ -41,29 +41,41 @@
 
         try
         {
-            _factory.createMessage(messasgeID, null);
-            fail("Cannot recreate message with an existing id");
+            _factory.createMessage(-1L, null);
+            fail("Cannot recreate message with a negative id");
         }
         catch (RuntimeException re)
         {
             assertEquals("Incorrect exception thrown ",
-                         "Message IDs can only increase current id is:" + messasgeID + ".
Requested:" + messasgeID, re.getMessage());
+                         "Message IDs can only be positive. Requested:-1", re.getMessage());
         }
 
-        //Check we cannot go backwords with ids.
+        //Check we CAN go backwords with ids.
         try
         {
-            _factory.createMessage(messasgeID - 1, null);
-            fail("Cannot recreate message with an old id");
+            _factory.createMessage(messasgeID - 1, null);            
         }
         catch (RuntimeException re)
         {
-            assertEquals("Incorrect exception thrown ",
-                         "Message IDs can only increase current id is:" + messasgeID + ".
Requested:" + (messasgeID - 1), re.getMessage());
+            fail(re.getMessage());
         }
 
         //Check that we can jump forward in ids during recovery.
         messasgeID += 100;
+        Long highestID=messasgeID;
+        try
+        {
+            AMQMessage message = _factory.createMessage(messasgeID, null);
+            assertEquals("Factory assigned incorrect id.", messasgeID, message.getMessageId());
           
+        }
+        catch (Exception re)
+        {
+            fail("Message with a much higher value should be created");
+        }
+
+
+        //Check that we can jump backwards in ids during recovery.
+        messasgeID -= 75;
         try
         {
             AMQMessage message = _factory.createMessage(messasgeID, null);
@@ -91,12 +103,12 @@
 
         // Check that the next message created has the next available id
 
-        messasgeID++;
+        highestID++;
 
         try
         {
             AMQMessage message = _factory.createMessage(null, false);
-            assertEquals("Factory assigned incorrect id.", messasgeID, message.getMessageId());
+            assertEquals("Factory assigned incorrect id.", highestID, message.getMessageId());
         }
         catch (Exception re)
         {



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message