You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/05/16 07:04:33 UTC

(camel) branch redis-flush created (now b8d80048c4c)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch redis-flush
in repository https://gitbox.apache.org/repos/asf/camel.git


      at b8d80048c4c CAMEL-20768: camel-spring-redis - SpringRedisIdempotentRepository flushes DB on start

This branch includes the following new commits:

     new b8d80048c4c CAMEL-20768: camel-spring-redis - SpringRedisIdempotentRepository flushes DB on start

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(camel) 01/01: CAMEL-20768: camel-spring-redis - SpringRedisIdempotentRepository flushes DB on start

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch redis-flush
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b8d80048c4ceeeefe1969cc4565b13a89eeab743
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu May 16 09:03:51 2024 +0200

    CAMEL-20768: camel-spring-redis - SpringRedisIdempotentRepository flushes DB on start
---
 .../beans/SpringRedisIdempotentRepository.json        |  2 +-
 .../SpringRedisIdempotentRepositoryConfigurer.java    |  6 ++++++
 .../camel/bean/SpringRedisIdempotentRepository.json   |  2 +-
 .../idempotent/SpringRedisIdempotentRepository.java   | 19 ++++++++++++++++++-
 4 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/SpringRedisIdempotentRepository.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/SpringRedisIdempotentRepository.json
index 715dbbf12ce..c73efef56b7 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/SpringRedisIdempotentRepository.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/SpringRedisIdempotentRepository.json
@@ -10,7 +10,7 @@
     "groupId": "org.apache.camel",
     "artifactId": "camel-spring-redis",
     "version": "4.7.0-SNAPSHOT",
-    "properties": { "repositoryName": { "index": 0, "kind": "property", "displayName": "Repository Name", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of repository" }, "redisConfiguration": { "index": 1, "kind": "property", "displayName": "Redis Configuration", "required": false, "type": "object", "javaType": "org.apache.camel.component.redis.RedisConfiguration", "deprecated": false, "a [...]
+    "properties": { "repositoryName": { "index": 0, "kind": "property", "displayName": "Repository Name", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of repository" }, "redisConfiguration": { "index": 1, "kind": "property", "displayName": "Redis Configuration", "required": false, "type": "object", "javaType": "org.apache.camel.component.redis.RedisConfiguration", "deprecated": false, "a [...]
   }
 }
 
diff --git a/components/camel-spring-redis/src/generated/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryConfigurer.java b/components/camel-spring-redis/src/generated/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryConfigurer.java
index e5ffc4b7cf4..dedd38d59b6 100644
--- a/components/camel-spring-redis/src/generated/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryConfigurer.java
+++ b/components/camel-spring-redis/src/generated/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepositoryConfigurer.java
@@ -23,6 +23,8 @@ public class SpringRedisIdempotentRepositoryConfigurer extends org.apache.camel.
     public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
         org.apache.camel.component.redis.processor.idempotent.SpringRedisIdempotentRepository target = (org.apache.camel.component.redis.processor.idempotent.SpringRedisIdempotentRepository) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
+        case "flushonstartup":
+        case "flushOnStartup": target.setFlushOnStartup(property(camelContext, boolean.class, value)); return true;
         case "repositoryname":
         case "repositoryName": target.setRepositoryName(property(camelContext, java.lang.String.class, value)); return true;
         default: return false;
@@ -32,6 +34,8 @@ public class SpringRedisIdempotentRepositoryConfigurer extends org.apache.camel.
     @Override
     public Class<?> getOptionType(String name, boolean ignoreCase) {
         switch (ignoreCase ? name.toLowerCase() : name) {
+        case "flushonstartup":
+        case "flushOnStartup": return boolean.class;
         case "repositoryname":
         case "repositoryName": return java.lang.String.class;
         default: return null;
@@ -42,6 +46,8 @@ public class SpringRedisIdempotentRepositoryConfigurer extends org.apache.camel.
     public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
         org.apache.camel.component.redis.processor.idempotent.SpringRedisIdempotentRepository target = (org.apache.camel.component.redis.processor.idempotent.SpringRedisIdempotentRepository) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
+        case "flushonstartup":
+        case "flushOnStartup": return target.isFlushOnStartup();
         case "repositoryname":
         case "repositoryName": return target.getRepositoryName();
         default: return null;
diff --git a/components/camel-spring-redis/src/generated/resources/META-INF/services/org/apache/camel/bean/SpringRedisIdempotentRepository.json b/components/camel-spring-redis/src/generated/resources/META-INF/services/org/apache/camel/bean/SpringRedisIdempotentRepository.json
index 715dbbf12ce..c73efef56b7 100644
--- a/components/camel-spring-redis/src/generated/resources/META-INF/services/org/apache/camel/bean/SpringRedisIdempotentRepository.json
+++ b/components/camel-spring-redis/src/generated/resources/META-INF/services/org/apache/camel/bean/SpringRedisIdempotentRepository.json
@@ -10,7 +10,7 @@
     "groupId": "org.apache.camel",
     "artifactId": "camel-spring-redis",
     "version": "4.7.0-SNAPSHOT",
-    "properties": { "repositoryName": { "index": 0, "kind": "property", "displayName": "Repository Name", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of repository" }, "redisConfiguration": { "index": 1, "kind": "property", "displayName": "Redis Configuration", "required": false, "type": "object", "javaType": "org.apache.camel.component.redis.RedisConfiguration", "deprecated": false, "a [...]
+    "properties": { "repositoryName": { "index": 0, "kind": "property", "displayName": "Repository Name", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of repository" }, "redisConfiguration": { "index": 1, "kind": "property", "displayName": "Redis Configuration", "required": false, "type": "object", "javaType": "org.apache.camel.component.redis.RedisConfiguration", "deprecated": false, "a [...]
   }
 }
 
diff --git a/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java b/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
index 443df8b0db3..bd74366b369 100644
--- a/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
+++ b/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/processor/idempotent/SpringRedisIdempotentRepository.java
@@ -41,6 +41,9 @@ public class SpringRedisIdempotentRepository extends ServiceSupport implements I
     @Metadata(description = "Redis configuration")
     private RedisConfiguration redisConfiguration;
     private RedisTemplate<String, String> redisTemplate;
+    @Metadata(label = "advanced", description = "Delete all keys of the currently selected database."
+                                                + " Be careful if enabling this as all existing data will be deleted.")
+    private boolean flushOnStartup;
 
     public SpringRedisIdempotentRepository() {
     }
@@ -64,6 +67,18 @@ public class SpringRedisIdempotentRepository extends ServiceSupport implements I
         return new SpringRedisIdempotentRepository(redisTemplate, processorName);
     }
 
+    public boolean isFlushOnStartup() {
+        return flushOnStartup;
+    }
+
+    /**
+     * Delete all keys of the currently selected database. Be careful if enabling this as all existing data will be
+     * deleted.
+     */
+    public void setFlushOnStartup(boolean flushOnStartup) {
+        this.flushOnStartup = flushOnStartup;
+    }
+
     @Override
     @ManagedOperation(description = "Adds the key to the store")
     public boolean add(String key) {
@@ -117,7 +132,9 @@ public class SpringRedisIdempotentRepository extends ServiceSupport implements I
         }
         ObjectHelper.notNull(this.redisTemplate, "redisTemplate", this);
         this.setOperations = redisTemplate.opsForSet();
-        redisTemplate.getConnectionFactory().getConnection().flushDb();
+        if (flushOnStartup) {
+            redisTemplate.getConnectionFactory().getConnection().flushDb();
+        }
     }
 
     @Override