diff options
| author | Robert Gemmell <robbie@apache.org> | 2009-12-29 17:06:33 +0000 |
|---|---|---|
| committer | Robert Gemmell <robbie@apache.org> | 2009-12-29 17:06:33 +0000 |
| commit | 90f0ed8f2eae16d7c7730007704200f2959e83c4 (patch) | |
| tree | b1310b660bf7be125123099ee515992193c67710 | |
| parent | d2802522c0797e17329c6677ac5fda909eb522a5 (diff) | |
| download | qpid-python-90f0ed8f2eae16d7c7730007704200f2959e83c4.tar.gz | |
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
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.5.x-dev@894442 13f79535-47bb-0310-9956-ffa450edef68
| -rw-r--r-- | qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java | 22 | ||||
| -rw-r--r-- | qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java | 20 |
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 b6c8f53cdc..4c0c4fa82b 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 @@ -115,6 +115,7 @@ public class DerbyMessageStore extends AbstractMessageStore 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 @@ public class DerbyMessageStore extends AbstractMessageStore { 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/VirtualHost.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java index 925580a97e..8f035f96b3 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java @@ -185,28 +185,8 @@ public class VirtualHost implements Accessable // 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; |
