[jboss-cvs] JBoss Messaging SVN: r3040 - trunk/src/main/org/jboss/messaging/core/impl.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 23 10:21:51 EDT 2007


Author: timfox
Date: 2007-08-23 10:21:51 -0400 (Thu, 23 Aug 2007)
New Revision: 3040

Modified:
   trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java
Log:
Put reaper in retry block


Modified: trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java	2007-08-23 14:11:28 UTC (rev 3039)
+++ trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java	2007-08-23 14:21:51 UTC (rev 3040)
@@ -2218,44 +2218,42 @@
       return order;
    }
    
-   private void reapUnreferencedMessages(long timestamp) throws Exception
+   private void reapUnreferencedMessages(final long timestamp) throws Exception
    {
-   	 Connection conn = null;
-       PreparedStatement ps = null;
-       TransactionWrapper wrap = new TransactionWrapper();
-       
-       int rows = -1;
-       
-   	 long start = System.currentTimeMillis();
-   	        
-       try
-       {
-          conn = ds.getConnection();
-          
-          ps = conn.prepareStatement(getSQLStatement("REAP_MESSAGES"));
-          
-          ps.setLong(1, timestamp);
-          
-          rows = ps.executeUpdate();             
-       }
-       catch (Exception e)
-       {
-          wrap.exceptionOccurred();
-          throw e;
-       }
-       finally
-       {
-       	closeStatement(ps);
-       	closeConnection(conn);
-         wrap.end();
-         
-         long end = System.currentTimeMillis();
-         
-         if (trace) { log.trace("Reaper reaped " + rows + " messages in " + (end - start) + " ms"); }
-       }   	
+   	class ReaperRunner extends JDBCTxRunner
+   	{
+			public Object doTransaction() throws Exception
+			{
+				PreparedStatement ps = null;
+			   
+		       int rows = -1;
+		       		   	      
+		       try
+		       {
+		          ps = conn.prepareStatement(getSQLStatement("REAP_MESSAGES"));
+		          
+		          ps.setLong(1, timestamp);
+		          
+		          rows = ps.executeUpdate();
+		          
+		          return rows;
+		       }		       
+		       finally
+		       {
+		       	closeStatement(ps);		         		        
+		       }
+			}   		
+   	}
+   	
+   	long start = System.currentTimeMillis();
+	   
+   	int rows = (Integer)new ReaperRunner().executeWithRetry();
+   	 
+   	long end = System.currentTimeMillis();
+      
+      if (trace) { log.trace("Reaper reaped " + rows + " messages in " + (end - start) + " ms"); }
    }
-  
-   
+     
    // Inner classes -------------------------------------------------
             
    private class Reaper extends TimerTask




More information about the jboss-cvs-commits mailing list