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 2018/09/05 12:11:51 UTC

[camel] branch camel-2.22.x updated: CAMEL-12779: camel-spring-redis - When stopping consumer it should stop the message listener

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

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


The following commit(s) were added to refs/heads/camel-2.22.x by this push:
     new b27897f  CAMEL-12779: camel-spring-redis - When stopping consumer it should stop the message listener
b27897f is described below

commit b27897fa35e7d0f0f281048cd9549781e1157dee
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Sep 5 14:09:10 2018 +0200

    CAMEL-12779: camel-spring-redis - When stopping consumer it should stop the message listener
---
 .../main/java/org/apache/camel/component/redis/RedisConsumer.java  | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisConsumer.java b/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisConsumer.java
index e0fe095..e44a807 100644
--- a/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisConsumer.java
+++ b/components/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisConsumer.java
@@ -46,6 +46,13 @@ public class RedisConsumer extends DefaultConsumer implements MessageListener {
         redisConfiguration.getListenerContainer().addMessageListener(this, topics);
     }
 
+    @Override
+    protected void doStop() throws Exception {
+        Collection<Topic> topics = toTopics(redisConfiguration.getChannels());
+        redisConfiguration.getListenerContainer().removeMessageListener(this, topics);
+        super.doStop();
+    }
+
     private Collection<Topic> toTopics(String channels) {
         String[] channelsArrays = channels.split(",");
         List<Topic> topics = new ArrayList<>();