summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2010-01-04 18:13:37 +0000
committerRobert Gemmell <robbie@apache.org>2010-01-04 18:13:37 +0000
commit9868b7cc25c99f92c1ad645117e44fbdb189c335 (patch)
tree08db84a3c381ad95c6fed15aefa2e5b109c74a78
parent6a078e2e8c8778e10371cb49b3593b561f40a567 (diff)
downloadqpid-python-9868b7cc25c99f92c1ad645117e44fbdb189c335.tar.gz
QPID-2308: Update the DerbyStore createExchange() method to check for existing exchange entry in the store first. 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
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@895736 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java22
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java20
2 files changed, 16 insertions, 26 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
index 1764e2324e..5ca75aa9ae 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
@@ -101,6 +101,7 @@ public class DerbyMessageStore implements MessageStore
"SELECT * FROM " + BINDINGS_TABLE_NAME + " WHERE exchange_name = ? AND queue_name = ? AND binding_key = ? ";
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 @@ public class DerbyMessageStore implements MessageStore
{
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
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
index 9c4913e1af..48581c0290 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
@@ -189,28 +189,8 @@ public class VirtualHostImpl implements Accessable, VirtualHost
// 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;