You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2010/01/04 19:13:38 UTC
svn commit: r895736 - in
/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server:
store/DerbyMessageStore.java virtualhost/VirtualHostImpl.java
Author: robbie
Date: Mon Jan 4 18:13:37 2010
New Revision: 895736
URL: http://svn.apache.org/viewvc?rev=895736&view=rev
Log:
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
Modified:
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java?rev=895736&r1=895735&r2=895736&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/store/DerbyMessageStore.java Mon Jan 4 18:13:37 2010
@@ -101,6 +101,7 @@
"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 @@
{
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/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java?rev=895736&r1=895735&r2=895736&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java Mon Jan 4 18:13:37 2010
@@ -189,28 +189,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