qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject svn commit: r894442 - in /qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server: store/DerbyMessageStore.java virtualhost/VirtualHost.java
Date Tue, 29 Dec 2009 17:06:34 GMT
Author: robbie
Date: Tue Dec 29 17:06:33 2009
New Revision: 894442

URL: http://svn.apache.org/viewvc?rev=894442&view=rev
Log:
QPID-2308: Update the DerbyStore createExchange() method to check for existing exchange entry
in the store first, and remove the no-longer-required workarounds for QPID-2096 that prevent
addition of the default and config-defined durable exchanges to the store at startup and so
lead to failure to recover the associated bindings on subsequent store recovery cycles

Modified:
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java?rev=894442&r1=894441&r2=894442&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
Tue Dec 29 17:06:33 2009
@@ -115,6 +115,7 @@
     private static final String DELETE_FROM_MESSAGE_CONTENT = "DELETE FROM " + MESSAGE_CONTENT_TABLE_NAME
+ " WHERE message_id = ?";
     private static final String INSERT_INTO_EXCHANGE = "INSERT INTO " + EXCHANGE_TABLE_NAME
+ " ( name, type, autodelete ) VALUES ( ?, ?, ? )";
     private static final String DELETE_FROM_EXCHANGE = "DELETE FROM " + EXCHANGE_TABLE_NAME
+ " WHERE name = ?";
+    private static final String FIND_EXCHANGE = "SELECT name FROM " + EXCHANGE_TABLE_NAME
+ " WHERE name = ?";
     private static final String INSERT_INTO_BINDINGS = "INSERT INTO " + BINDINGS_TABLE_NAME
+ " ( exchange_name, queue_name, binding_key, arguments ) values ( ?, ?, ?, ? )";
     private static final String DELETE_FROM_BINDINGS = "DELETE FROM " + BINDINGS_TABLE_NAME
+ " WHERE exchange_name = ? AND queue_name = ? AND binding_key = ?";
     private static final String INSERT_INTO_QUEUE = "INSERT INTO " + QUEUE_TABLE_NAME + "
(name, owner) VALUES (?, ?)";
@@ -588,13 +589,22 @@
                 {
                     conn = newConnection();
 
-                    PreparedStatement stmt = conn.prepareStatement(INSERT_INTO_EXCHANGE);
+                    PreparedStatement stmt = conn.prepareStatement(FIND_EXCHANGE);
                     stmt.setString(1, exchange.getName().toString());
-                    stmt.setString(2, exchange.getType().toString());
-                    stmt.setShort(3, exchange.isAutoDelete() ? (short) 1 : (short) 0);
-                    stmt.execute();
-                    stmt.close();
-                    conn.commit();
+
+                    ResultSet rs = stmt.executeQuery();
+
+                    // If we don't have any data in the result set then we can add this exchange
+                    if (!rs.next())
+                    {
+                        stmt = conn.prepareStatement(INSERT_INTO_EXCHANGE);
+                        stmt.setString(1, exchange.getName().toString());
+                        stmt.setString(2, exchange.getType().toString());
+                        stmt.setShort(3, exchange.isAutoDelete() ? (short) 1 : (short) 0);
+                        stmt.execute();
+                        stmt.close();
+                        conn.commit();
+                    }
 
                 }
                 finally

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java?rev=894442&r1=894441&r2=894442&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
Tue Dec 29 17:06:33 2009
@@ -185,28 +185,8 @@
         // This needs to be after the RT has been defined as it creates the default durable
exchanges.
         _exchangeRegistry.initialise();
 
-        // We don't need to store the Default queues in the store as we always
-        // create them first on start up so don't clear them from the startup
-        // configuration here. This also ensures that we don't attempt to
-        // perform a createExchange twice with the same details in the
-        // MessageStore(RoutingTable) as some instances may not like that.
-        // Derby being one.
-        // todo this can be removed with the resolution fo QPID-2096
-        configFileRT.exchange.clear();
-        
         initialiseModel(hostConfig);
 
-        //todo REMOVE Work Around for QPID-2096
-        // This means that all durable exchanges declared in the configuration
-        // will not be stored in the MessageStore.
-        // They will still be created/registered/available on startup for as
-        // long as they are contained in the configuration. However, when they
-        // are removed from the configuration they will no longer exist.
-        // This differs from durable queues as they will be writen to to the
-        // store. After QPID-2096 has been resolved exchanges will mirror that
-        // functionality.
-        configFileRT.exchange.clear();
-
         if (store != null)
         {
             _messageStore = store;



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


Mime
View raw message