[jboss-cvs] JBoss Messaging SVN: r3071 - in trunk/src: main/org/jboss/messaging/core/impl and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 29 11:06:53 EDT 2007


Author: clebert.suconic at jboss.com
Date: 2007-08-29 11:06:53 -0400 (Wed, 29 Aug 2007)
New Revision: 3071

Modified:
   trunk/src/etc/server/default/deploy/db2-persistence-service.xml
   trunk/src/etc/server/default/deploy/mssql-persistence-service.xml
   trunk/src/etc/server/default/deploy/mysql-persistence-service.xml
   trunk/src/etc/server/default/deploy/oracle-persistence-service.xml
   trunk/src/etc/server/default/deploy/postgresql-persistence-service.xml
   trunk/src/etc/server/default/deploy/sybase-persistence-service.xml
   trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-1060

Modified: trunk/src/etc/server/default/deploy/db2-persistence-service.xml
===================================================================
--- trunk/src/etc/server/default/deploy/db2-persistence-service.xml	2007-08-29 15:02:38 UTC (rev 3070)
+++ trunk/src/etc/server/default/deploy/db2-persistence-service.xml	2007-08-29 15:06:53 UTC (rev 3071)
@@ -60,8 +60,9 @@
    UPDATE_DELIVERY_COUNT=UPDATE JBM_MSG_REF SET DELIVERY_COUNT = ? WHERE CHANNEL_ID = ? AND MESSAGE_ID = ?
    UPDATE_CHANNEL_ID=UPDATE JBM_MSG_REF SET CHANNEL_ID = ? WHERE CHANNEL_ID = ?
    LOAD_MESSAGES=SELECT MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE FROM JBM_MSG
-   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
-   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) SELECT ?, ?, ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)   
+   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE, HEADERS, PAYLOAD) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE) SELECT ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)
+   UPDATE_MESSAGE_4CONDITIONAL=UPDATE JBM_MSG SET HEADERS=?, PAYLOAD=? WHERE MESSAGE_ID=?
    MESSAGE_ID_COLUMN=MESSAGE_ID
    REAP_MESSAGES=DELETE FROM JBM_MSG WHERE TIMESTAMP < ? AND NOT EXISTS (SELECT * FROM JBM_MSG_REF WHERE JBM_MSG_REF.MESSAGE_ID = JBM_MSG.MESSAGE_ID)
    INSERT_TRANSACTION=INSERT INTO JBM_TX (NODE_ID, TRANSACTION_ID, BRANCH_QUAL, FORMAT_ID, GLOBAL_TXID) VALUES(?, ?, ?, ?, ?)
@@ -75,7 +76,6 @@
    SELECT_ALL_CHANNELS=SELECT DISTINCT(CHANNEL_ID) FROM JBM_MSG_REF
    UPDATE_TX=UPDATE JBM_TX SET NODE_ID=? WHERE NODE_ID=?
    DUPLICATE_KEY_STATE=23505
-   SUPPORT_MESSAGE_CONDITIONAL=N
       ]]></attribute>
       
       <!-- The maximum number of parameters to include in a prepared statement -->

Modified: trunk/src/etc/server/default/deploy/mssql-persistence-service.xml
===================================================================
--- trunk/src/etc/server/default/deploy/mssql-persistence-service.xml	2007-08-29 15:02:38 UTC (rev 3070)
+++ trunk/src/etc/server/default/deploy/mssql-persistence-service.xml	2007-08-29 15:06:53 UTC (rev 3071)
@@ -63,8 +63,9 @@
    UPDATE_DELIVERY_COUNT=UPDATE JBM_MSG_REF SET DELIVERY_COUNT = ? WHERE CHANNEL_ID = ? AND MESSAGE_ID = ?
    UPDATE_CHANNEL_ID=UPDATE JBM_MSG_REF SET CHANNEL_ID = ? WHERE CHANNEL_ID = ?
    LOAD_MESSAGES=SELECT MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE FROM JBM_MSG
-   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
-   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) SELECT ?, ?, ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)   
+   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE, HEADERS, PAYLOAD) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE) SELECT ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)
+   UPDATE_MESSAGE_4CONDITIONAL=UPDATE JBM_MSG SET HEADERS=?, PAYLOAD=? WHERE MESSAGE_ID=?
    MESSAGE_ID_COLUMN=MESSAGE_ID
    REAP_MESSAGES=DELETE FROM JBM_MSG WHERE TIMESTAMP < ? AND NOT EXISTS (SELECT * FROM JBM_MSG_REF WHERE JBM_MSG_REF.MESSAGE_ID = JBM_MSG.MESSAGE_ID)   
    INSERT_TRANSACTION=INSERT INTO JBM_TX (NODE_ID, TRANSACTION_ID, BRANCH_QUAL, FORMAT_ID, GLOBAL_TXID) VALUES(?, ?, ?, ?, ?)
@@ -78,7 +79,6 @@
    SELECT_ALL_CHANNELS=SELECT DISTINCT(CHANNEL_ID) FROM JBM_MSG_REF
    UPDATE_TX=UPDATE JBM_TX SET NODE_ID=? WHERE NODE_ID=?
    DUPLICATE_KEY_STATE=23000
-   SUPPORT_MESSAGE_CONDITIONAL=Y
       ]]></attribute>
       
       <!-- The maximum number of parameters to include in a prepared statement -->

Modified: trunk/src/etc/server/default/deploy/mysql-persistence-service.xml
===================================================================
--- trunk/src/etc/server/default/deploy/mysql-persistence-service.xml	2007-08-29 15:02:38 UTC (rev 3070)
+++ trunk/src/etc/server/default/deploy/mysql-persistence-service.xml	2007-08-29 15:06:53 UTC (rev 3071)
@@ -63,8 +63,9 @@
    UPDATE_DELIVERY_COUNT=UPDATE JBM_MSG_REF SET DELIVERY_COUNT = ? WHERE CHANNEL_ID = ? AND MESSAGE_ID = ?
    UPDATE_CHANNEL_ID=UPDATE JBM_MSG_REF SET CHANNEL_ID = ? WHERE CHANNEL_ID = ?
    LOAD_MESSAGES=SELECT MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE FROM JBM_MSG
-   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?)      
-   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) SELECT ?, ?, ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)   
+   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE, HEADERS, PAYLOAD) VALUES (?, ?, ?, ?, ?, ?, ?, ?)      
+   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE) SELECT ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)
+   UPDATE_MESSAGE_4CONDITIONAL=UPDATE JBM_MSG SET HEADERS=?, PAYLOAD=? WHERE MESSAGE_ID=?
    MESSAGE_ID_COLUMN=MESSAGE_ID
    REAP_MESSAGES=DELETE FROM JBM_MSG WHERE TIMESTAMP < ? AND NOT EXISTS (SELECT * FROM JBM_MSG_REF WHERE JBM_MSG_REF.MESSAGE_ID = JBM_MSG.MESSAGE_ID)
    INSERT_TRANSACTION=INSERT INTO JBM_TX (NODE_ID, TRANSACTION_ID, BRANCH_QUAL, FORMAT_ID, GLOBAL_TXID) VALUES(?, ?, ?, ?, ?)
@@ -78,7 +79,6 @@
    SELECT_ALL_CHANNELS=SELECT DISTINCT(CHANNEL_ID) FROM JBM_MSG_REF
    UPDATE_TX=UPDATE JBM_TX SET NODE_ID=? WHERE NODE_ID=?
    DUPLICATE_KEY_STATE=23000
-   SUPPORT_MESSAGE_CONDITIONAL=Y
       ]]></attribute>
       
       <!-- The maximum number of parameters to include in a prepared statement -->

Modified: trunk/src/etc/server/default/deploy/oracle-persistence-service.xml
===================================================================
--- trunk/src/etc/server/default/deploy/oracle-persistence-service.xml	2007-08-29 15:02:38 UTC (rev 3070)
+++ trunk/src/etc/server/default/deploy/oracle-persistence-service.xml	2007-08-29 15:06:53 UTC (rev 3071)
@@ -63,8 +63,9 @@
    UPDATE_DELIVERY_COUNT=UPDATE JBM_MSG_REF SET DELIVERY_COUNT = ? WHERE CHANNEL_ID = ? AND MESSAGE_ID = ?
    UPDATE_CHANNEL_ID=UPDATE JBM_MSG_REF SET CHANNEL_ID = ? WHERE CHANNEL_ID = ?
    LOAD_MESSAGES=SELECT MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE FROM JBM_MSG
-   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
-   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) SELECT ?, ?, ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)   
+   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE, HEADERS, PAYLOAD) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE) SELECT ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)
+   UPDATE_MESSAGE_4CONDITIONAL=UPDATE JBM_MSG SET HEADERS=?, PAYLOAD=? WHERE MESSAGE_ID=?
    MESSAGE_ID_COLUMN=MESSAGE_ID
    REAP_MESSAGES=DELETE FROM JBM_MSG WHERE TIMESTAMP < ? AND NOT EXISTS (SELECT * FROM JBM_MSG_REF WHERE JBM_MSG_REF.MESSAGE_ID = JBM_MSG.MESSAGE_ID)
    INSERT_TRANSACTION=INSERT INTO JBM_TX (NODE_ID, TRANSACTION_ID, BRANCH_QUAL, FORMAT_ID, GLOBAL_TXID) VALUES(?, ?, ?, ?, ?)
@@ -78,7 +79,6 @@
    SELECT_ALL_CHANNELS=SELECT DISTINCT(CHANNEL_ID) FROM JBM_MSG_REF
    UPDATE_TX=UPDATE JBM_TX SET NODE_ID=? WHERE NODE_ID=?
    DUPLICATE_KEY_STATE=23000
-   SUPPORT_MESSAGE_CONDITIONAL=N
       ]]></attribute>
       
       <!-- The maximum number of parameters to include in a prepared statement -->

Modified: trunk/src/etc/server/default/deploy/postgresql-persistence-service.xml
===================================================================
--- trunk/src/etc/server/default/deploy/postgresql-persistence-service.xml	2007-08-29 15:02:38 UTC (rev 3070)
+++ trunk/src/etc/server/default/deploy/postgresql-persistence-service.xml	2007-08-29 15:06:53 UTC (rev 3071)
@@ -47,7 +47,8 @@
    CREATE_COUNTER=CREATE TABLE JBM_COUNTER (NAME VARCHAR(255), NEXT_ID BIGINT, PRIMARY KEY(NAME))
    INSERT_DUAL=INSERT INTO JBM_DUAL VALUES (1)
    INSERT_MESSAGE_REF=INSERT INTO JBM_MSG_REF (CHANNEL_ID, MESSAGE_ID, TRANSACTION_ID, STATE, ORD, PAGE_ORD, DELIVERY_COUNT, SCHED_DELIVERY) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
-   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) SELECT ?, ?, ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)   
+   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE) SELECT ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)
+   UPDATE_MESSAGE_4CONDITIONAL=UPDATE JBM_MSG SET HEADERS=?, PAYLOAD=? WHERE MESSAGE_ID=?
    DELETE_MESSAGE_REF=DELETE FROM JBM_MSG_REF WHERE MESSAGE_ID=? AND CHANNEL_ID=? AND STATE='C'
    UPDATE_MESSAGE_REF=UPDATE JBM_MSG_REF SET TRANSACTION_ID=?, STATE='-' WHERE MESSAGE_ID=? AND CHANNEL_ID=? AND STATE='C'
    UPDATE_PAGE_ORDER=UPDATE JBM_MSG_REF SET PAGE_ORD = ? WHERE MESSAGE_ID=? AND CHANNEL_ID=?
@@ -64,7 +65,7 @@
    UPDATE_DELIVERY_COUNT=UPDATE JBM_MSG_REF SET DELIVERY_COUNT = ? WHERE CHANNEL_ID = ? AND MESSAGE_ID = ?
    UPDATE_CHANNEL_ID=UPDATE JBM_MSG_REF SET CHANNEL_ID = ? WHERE CHANNEL_ID = ?
    LOAD_MESSAGES=SELECT MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE FROM JBM_MSG
-   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE, HEADERS, PAYLOAD) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
    MESSAGE_ID_COLUMN=MESSAGE_ID
    REAP_MESSAGES=DELETE FROM JBM_MSG WHERE TIMESTAMP < ? AND NOT EXISTS (SELECT * FROM JBM_MSG_REF WHERE JBM_MSG_REF.MESSAGE_ID = JBM_MSG.MESSAGE_ID)   
    INSERT_TRANSACTION=INSERT INTO JBM_TX (NODE_ID, TRANSACTION_ID, BRANCH_QUAL, FORMAT_ID, GLOBAL_TXID) VALUES(?, ?, ?, ?, ?)
@@ -78,7 +79,6 @@
    SELECT_ALL_CHANNELS=SELECT DISTINCT(CHANNEL_ID) FROM JBM_MSG_REF
    UPDATE_TX=UPDATE JBM_TX SET NODE_ID=? WHERE NODE_ID=?
    DUPLICATE_KEY_STATE=23505
-   SUPPORT_MESSAGE_CONDITIONAL=Y
       ]]></attribute>
       
       <!-- The maximum number of parameters to include in a prepared statement -->

Modified: trunk/src/etc/server/default/deploy/sybase-persistence-service.xml
===================================================================
--- trunk/src/etc/server/default/deploy/sybase-persistence-service.xml	2007-08-29 15:02:38 UTC (rev 3070)
+++ trunk/src/etc/server/default/deploy/sybase-persistence-service.xml	2007-08-29 15:06:53 UTC (rev 3071)
@@ -68,8 +68,9 @@
    UPDATE_DELIVERY_COUNT=UPDATE JBM_MSG_REF SET DELIVERY_COUNT = ? WHERE CHANNEL_ID = ? AND MESSAGE_ID = ?
    UPDATE_CHANNEL_ID=UPDATE JBM_MSG_REF SET CHANNEL_ID = ? WHERE CHANNEL_ID = ?
    LOAD_MESSAGES=SELECT MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE FROM JBM_MSG
-   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
-   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) SELECT ?, ?, ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)   
+   INSERT_MESSAGE=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE, HEADERS, PAYLOAD) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+   INSERT_MESSAGE_CONDITIONAL=INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, TIMESTAMP, PRIORITY, TYPE) SELECT ?, ?, ?, ?, ?, ? FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)
+   UPDATE_MESSAGE_4CONDITIONAL=UPDATE JBM_MSG SET HEADERS=?, PAYLOAD=? WHERE MESSAGE_ID=?   
    MESSAGE_ID_COLUMN=MESSAGE_ID
    REAP_MESSAGES=DELETE FROM JBM_MSG WHERE TIMESTAMP < ? AND NOT EXISTS (SELECT * FROM JBM_MSG_REF WHERE JBM_MSG_REF.MESSAGE_ID = JBM_MSG.MESSAGE_ID)   
    INSERT_TRANSACTION=INSERT INTO JBM_TX (NODE_ID, TRANSACTION_ID, BRANCH_QUAL, FORMAT_ID, GLOBAL_TXID) VALUES(?, ?, ?, ?, ?)
@@ -83,7 +84,6 @@
    SELECT_ALL_CHANNELS=SELECT DISTINCT(CHANNEL_ID) FROM JBM_MSG_REF
    UPDATE_TX=UPDATE JBM_TX SET NODE_ID=? WHERE NODE_ID=?
    DUPLICATE_KEY_STATE=23000
-   SUPPORT_MESSAGE_CONDITIONAL=Y
       ]]></attribute>
       
       <!-- The maximum number of parameters to include in a prepared statement -->

Modified: trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java	2007-08-29 15:02:38 UTC (rev 3070)
+++ trunk/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java	2007-08-29 15:06:53 UTC (rev 3071)
@@ -106,11 +106,6 @@
 
    private String duplicateKeyState;
 
-   // due to a nasty bug on the Oracle Driver, we have to behave differently on the Oracle Driver
-   // What is really disappointing..
-   // http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078923#4078923
-   private boolean supportMessageConditional;
-          
    // Constructors --------------------------------------------------
     
    public JDBCPersistenceManager(DataSource ds, TransactionManager tm, Properties sqlProperties,
@@ -144,8 +139,6 @@
 
       this.duplicateKeyState = this.getSQLStatement("DUPLICATE_KEY_STATE");
 
-      this.supportMessageConditional = this.getSQLStatement("SUPPORT_MESSAGE_CONDITIONAL").equals("Y");
-
       Connection conn = null;
       
       PreparedStatement ps = null;
@@ -563,21 +556,17 @@
    		{
       		PreparedStatement psInsertReference = null;
       		PreparedStatement psInsertMessage = null;
-      		
-      		try
+            PreparedStatement psUpdateMessage = null;
+
+            try
       		{      		
 	      		Iterator iter = references.iterator();
 	
 	         	psInsertReference = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE_REF"));
 
-               if (supportMessageConditional)
-               {
-                  psInsertMessage = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE_CONDITIONAL"));
-               }
-               else
-               {
-                  psInsertMessage = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE"));
-               }
+               psInsertMessage = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE_CONDITIONAL"));
+
+               psUpdateMessage = conn.prepareStatement(getSQLStatement("UPDATE_MESSAGE_4CONDITIONAL"));
 	
                while (iter.hasNext())
 	         	{
@@ -602,32 +591,20 @@
 	         		//Maybe we need to persist the message itself
 	         		Message m = ref.getMessage();
 
-                  storeMessage(m, psInsertMessage);
+                  storeMessage(m, psInsertMessage, false);
+                  psInsertMessage.setLong(7, m.getMessageID());
+                  rows = psInsertMessage.executeUpdate();
 
-                  if (supportMessageConditional)
+                  if (rows == 1)
                   {
-                     psInsertMessage.setLong(9, m.getMessageID());
-                     rows = psInsertMessage.executeUpdate();
-                  }
-                  else
-                  {
-                     try
+                     bindBlobs(m, psUpdateMessage, 1, 2);
+                     psUpdateMessage.setLong(3, m.getMessageID());
+                     rows = psUpdateMessage.executeUpdate();
+                     if (rows != 1)
                      {
-                        rows = psInsertMessage.executeUpdate();
+                        throw new IllegalStateException("Couldn't update messageId=" +
+                           m.getMessageID() + " on paging");
                      }
-                     catch (SQLException e)
-                     {
-                        rows = 0;
-                        if (e.getSQLState().equals(duplicateKeyState))
-                        {
-                           // do nothing...
-                           log.debug("Duplicate key being ignored on storeMessage");
-                        }
-                        else
-                        {
-                           throw e;
-                        }
-                     }
                   }
 
                   if (trace) { log.trace("Inserted " + rows + " rows"); }
@@ -1172,7 +1149,7 @@
 	               // First time so persist the message
 	               psMessage = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE"));
 	               
-	               storeMessage(m, psMessage);
+	               storeMessage(m, psMessage, true);
 	                                    
 		            rows = psMessage.executeUpdate();
 		            
@@ -1403,7 +1380,7 @@
 			            	}
 			            	
 			               // First time so add message
-			               storeMessage(m, psInsertMessage);
+			               storeMessage(m, psInsertMessage, true);
 			                 
 		                  if (trace) { log.trace("Message does not already exist so inserting it"); }
 		                  rows = psInsertMessage.executeUpdate();
@@ -1554,7 +1531,7 @@
 			            		psInsertMessage = conn.prepareStatement(getSQLStatement("INSERT_MESSAGE"));
 			            	}
 				            		
-				            storeMessage(m, psInsertMessage);               
+				            storeMessage(m, psInsertMessage, true);               
 				            
 				            rows = psInsertMessage.executeUpdate();
 			
@@ -1842,7 +1819,7 @@
    /**
     * Stores the message in the MESSAGE table.
     */
-   protected void storeMessage(Message m, PreparedStatement ps) throws Exception
+   protected void storeMessage(Message m, PreparedStatement ps, boolean bindBlobs) throws Exception
    {      
       // physically insert the row in the database
       // first set the fields from org.jboss.messaging.core.Routable
@@ -1851,32 +1828,42 @@
       ps.setLong(3, m.getExpiration());
       ps.setLong(4, m.getTimestamp());
       ps.setByte(5, m.getPriority());
-      
+
+      ps.setByte(6, m.getType());
+
+      if (bindBlobs)
+      {
+         bindBlobs(m, ps, 7, 8);
+
+      }
+   }
+
+   private void bindBlobs(Message m, PreparedStatement ps, int headerPosition, int payloadPosition)
+      throws Exception
+   {
       //headers
       byte[] bytes = mapToBytes(((MessageSupport) m).getHeaders());
       if (bytes != null)
       {
-         setBytes(ps, 6, bytes);
+         setBytes(ps, headerPosition, bytes);
       }
       else
       {
-         ps.setNull(6, Types.LONGVARBINARY);
+         ps.setNull(headerPosition, Types.LONGVARBINARY);
       }
-      
-      
+
+
       byte[] payload = m.getPayloadAsByteArray();
       if (payload != null)
       {
-         setBytes(ps, 7, payload);
+         setBytes(ps, payloadPosition, payload);
       }
       else
       {
-         ps.setNull(7, Types.LONGVARBINARY);
+         ps.setNull(payloadPosition, Types.LONGVARBINARY);
       }
-      
-      ps.setByte(8, m.getType());
    }
-   
+
    protected void setVarBinaryColumn(int column, PreparedStatement ps, byte[] bytes) throws Exception
    {
       if (usingTrailingByte)
@@ -2090,10 +2077,11 @@
               "VALUES (?, ?, ?, ?, ?, ?, ?, ?)" );
       map.put("INSERT_MESSAGE_CONDITIONAL",
       		  "INSERT INTO JBM_MSG (MESSAGE_ID, RELIABLE, EXPIRATION, " +
-              "TIMESTAMP, PRIORITY, HEADERS, PAYLOAD, TYPE) " +     
-              "SELECT ?, ?, ?, ?, ?, ?, ?, ? " + 
-              "FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)");	
-      map.put("MESSAGE_ID_COLUMN", "MESSAGE_ID");     
+              "TIMESTAMP, PRIORITY, TYPE) " +
+              "SELECT ?, ?, ?, ?, ?, ? " + 
+              "FROM JBM_DUAL WHERE NOT EXISTS (SELECT MESSAGE_ID FROM JBM_MSG WHERE MESSAGE_ID = ?)");
+      map.put("UPDATE_MESSAGE_4CONDITIONAL", "UPDATE JBM_MSG SET HEADERS=?, PAYLOAD=? WHERE MESSAGE_ID=?");
+      map.put("MESSAGE_ID_COLUMN", "MESSAGE_ID");
       map.put("REAP_MESSAGES", "DELETE FROM JBM_MSG WHERE TIMESTAMP <= ? AND NOT EXISTS (SELECT * FROM JBM_MSG_REF WHERE JBM_MSG_REF.MESSAGE_ID = JBM_MSG.MESSAGE_ID)");
       //Transaction
       map.put("INSERT_TRANSACTION",
@@ -2112,7 +2100,6 @@
       //Other
       map.put("SELECT_ALL_CHANNELS", "SELECT DISTINCT(CHANNEL_ID) FROM JBM_MSG_REF");
       map.put("DUPLICATE_KEY_STATE","23000");
-      map.put("SUPPORT_MESSAGE_CONDITIONAL", "Y");
 
       return map;
    }




More information about the jboss-cvs-commits mailing list