camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1225926 - /camel/trunk/components/camel-sql/src/main/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepository.java
Date Fri, 30 Dec 2011 21:28:47 GMT
Author: cmueller
Date: Fri Dec 30 21:28:46 2011
New Revision: 1225926

URL: http://svn.apache.org/viewvc?rev=1225926&view=rev
Log:
CAMEL-4152: jdbc idempotent repository - table creation

Modified:
    camel/trunk/components/camel-sql/src/main/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepository.java

Modified: camel/trunk/components/camel-sql/src/main/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepository.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-sql/src/main/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepository.java?rev=1225926&r1=1225925&r2=1225926&view=diff
==============================================================================
--- camel/trunk/components/camel-sql/src/main/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepository.java
(original)
+++ camel/trunk/components/camel-sql/src/main/java/org/apache/camel/processor/idempotent/jdbc/JdbcMessageIdRepository.java
Fri Dec 30 21:28:46 2011
@@ -30,6 +30,7 @@ import org.springframework.transaction.s
  */
 public class JdbcMessageIdRepository extends AbstractJdbcMessageIdRepository<String>
{
 
+    private boolean createTableIfNotExists = true;
     private String tableExistsString = "SELECT 1 FROM CAMEL_MESSAGEPROCESSED WHERE 1 = 0";
     private String createString = "CREATE TABLE CAMEL_MESSAGEPROCESSED (processorName VARCHAR(255),
messageId VARCHAR(100), createdAt TIMESTAMP)";
     private String queryString = "SELECT COUNT(*) FROM CAMEL_MESSAGEPROCESSED WHERE processorName
= ? AND messageId = ?";
@@ -63,15 +64,19 @@ public class JdbcMessageIdRepository ext
                     jdbcTemplate.execute(tableExistsString);
                     log.debug("table for JdbcMessageIdRepository already exists");
                 } catch (DataAccessException e) {
-                    log.debug("creating table for JdbcMessageIdRepository because it doesn't
exists...");
-                    log.debug("executing query '{}'...", createString);
-                    // we will fail if we cannot create it
-                    jdbcTemplate.execute(createString);
-                    log.info("table created");
+                    if (createTableIfNotExists) {
+                        log.debug("creating table for JdbcMessageIdRepository because it
doesn't exists...");
+                        // we will fail if we cannot create it
+                        jdbcTemplate.execute(createString);
+                        log.info("table created with query '{}'", createString);
+                    } else {
+                        throw e;
+                    }
+
                 }
                 return Boolean.TRUE;
             }
-        });
+        });   
     }
 
     @Override
@@ -88,7 +93,15 @@ public class JdbcMessageIdRepository ext
     protected int delete(String key) {
         return jdbcTemplate.update(deleteString, processorName, key);
     }
-    
+
+    public boolean isCreateTableIfNotExists() {
+        return createTableIfNotExists;
+    }
+
+    public void setCreateTableIfNotExists(boolean createTableIfNotExists) {
+        this.createTableIfNotExists = createTableIfNotExists;
+    }
+
     public String getTableExistsString() {
         return tableExistsString;
     }



Mime
View raw message