[Jboss-cvs] JBossAS SVN: r57013 - in trunk/messaging/src/main/org/jboss/mq: . kernel pm/jdbc2
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 20 11:26:48 EDT 2006
Author: adrian at jboss.org
Date: 2006-09-20 11:26:44 -0400 (Wed, 20 Sep 2006)
New Revision: 57013
Modified:
trunk/messaging/src/main/org/jboss/mq/SpyXAConnection.java
trunk/messaging/src/main/org/jboss/mq/kernel/Queue.java
trunk/messaging/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java
trunk/messaging/src/main/org/jboss/mq/pm/jdbc2/PersistenceManagerMBean.java
Log:
Synch jbossmq between the 4.0 and 5.0 branches.
Modified: trunk/messaging/src/main/org/jboss/mq/SpyXAConnection.java
===================================================================
--- trunk/messaging/src/main/org/jboss/mq/SpyXAConnection.java 2006-09-20 15:26:21 UTC (rev 57012)
+++ trunk/messaging/src/main/org/jboss/mq/SpyXAConnection.java 2006-09-20 15:26:44 UTC (rev 57013)
@@ -89,6 +89,7 @@
{
checkClosed();
checkClientID();
+
XASession session = new SpySession(this, true, 0, true);
//add the new session to the createdSessions list
synchronized (createdSessions)
@@ -127,12 +128,4 @@
}
return session;
}
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
}
\ No newline at end of file
Modified: trunk/messaging/src/main/org/jboss/mq/kernel/Queue.java
===================================================================
--- trunk/messaging/src/main/org/jboss/mq/kernel/Queue.java 2006-09-20 15:26:21 UTC (rev 57012)
+++ trunk/messaging/src/main/org/jboss/mq/kernel/Queue.java 2006-09-20 15:26:44 UTC (rev 57013)
@@ -85,8 +85,6 @@
getServer().invoke(securityManager, "addDestination", new Object[]{spyDest.getName(), securityConf}, new String[]{"java.lang.String", "org.w3c.dom.Element"});
}
*/
- System.out.println("!!!!! start " + destinationName);
- log.info("!!!!! start " + destinationName);
if (destinationName == null || destinationName.length() == 0)
{
throw new javax.jms.IllegalStateException("QueueName was not set");
Modified: trunk/messaging/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java
===================================================================
--- trunk/messaging/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java 2006-09-20 15:26:21 UTC (rev 57012)
+++ trunk/messaging/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java 2006-09-20 15:26:44 UTC (rev 57013)
@@ -106,6 +106,9 @@
/** The recover messages chunk */
private int recoverMessagesChunk = 0;
+ /** The statement retries */
+ private int statementRetries = 5;
+
/////////////////////////////////////////////////////////////////////////////////
//
// JDBC Access Attributes
@@ -1368,10 +1371,6 @@
stmt = c.prepareStatement(DELETE_MESSAGE);
stmt.setLong(1, messageRef.messageId);
stmt.setString(2, messageRef.getPersistentKey());
- int rc = stmt.executeUpdate();
- if (rc != 1)
- throw new SpyJMSException(
- "Could not delete the message from the database: delete affected " + rc + " rows");
// Adrian Brock:
// Remove the message from the cache, but don't
@@ -1392,16 +1391,45 @@
stmt.setString(2, "D");
stmt.setLong(3, messageRef.messageId);
stmt.setString(4, messageRef.getPersistentKey());
- int rc = stmt.executeUpdate();
- if (rc != 1)
- throw new SpyJMSException(
- "Could not mark the message as deleted in the database: update affected " + rc + " rows");
}
+
+ int tries = 0;
+ while (true)
+ {
+ try
+ {
+ int rc = stmt.executeUpdate();
+
+ if (tries > 0)
+ {
+ if (rc != 1)
+ throw new SpyJMSException(
+ "Could not mark the message as deleted in the database: update affected " + rc + " rows");
+
+ log.warn("Remove operation worked after " +tries +" retries");
+ }
+ break;
+ }
+ catch (SQLException e)
+ {
+ log.warn("SQLException caught - assuming deadlock detected, try:" + (tries + 1), e);
+ tries++;
+ if (tries >= statementRetries)
+ {
+ log.error("Retried " + tries + " times, now giving up");
+ throw new IllegalStateException("Could not remove message after " +tries + "attempts");
+ }
+ log.warn("Trying again after a pause");
+ //Now we wait for a random amount of time to minimise risk of deadlock
+ Thread.sleep((long)(Math.random() * 500));
+ }
+ }
+
if (trace)
log.trace("Removed message " + messageRef + " transaction=" + txId);
}
}
- catch (SQLException e)
+ catch (Exception e)
{
tms.setRollbackOnly();
throw new SpyJMSException("Could not remove message: " + messageRef, e);
@@ -1914,4 +1942,16 @@
{
this.xaRecovery = xaRecovery;
}
+
+ public int getStatementRetries()
+ {
+ return statementRetries;
+ }
+
+ public void setStatementRetries(int statementRetries)
+ {
+ if (statementRetries < 0)
+ statementRetries = 0;
+ this.statementRetries = statementRetries;
+ }
}
Modified: trunk/messaging/src/main/org/jboss/mq/pm/jdbc2/PersistenceManagerMBean.java
===================================================================
--- trunk/messaging/src/main/org/jboss/mq/pm/jdbc2/PersistenceManagerMBean.java 2006-09-20 15:26:21 UTC (rev 57012)
+++ trunk/messaging/src/main/org/jboss/mq/pm/jdbc2/PersistenceManagerMBean.java 2006-09-20 15:26:44 UTC (rev 57013)
@@ -140,4 +140,18 @@
* @param xaRecovery the xaRecovery.
*/
void setXARecovery(boolean xaRecovery);
+
+ /**
+ * Get the statement retries
+ *
+ * @return the retries
+ */
+ int getStatementRetries();
+
+ /**
+ * Set the statement retries
+ *
+ * @param statementRetries the retries
+ */
+ void setStatementRetries(int statementRetries);
}
More information about the jboss-cvs-commits
mailing list