Repository: camel Updated Branches: refs/heads/master 31d91911a -> ed4d1fa89
CAMEL-9267: camel-nats, unsubscribe from topic before stopping consumer Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/939a8951 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/939a8951 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/939a8951 Branch: refs/heads/master Commit: 939a89514ceaeee8633523a70c03ae02fc4c4d45 Parents: 31d9191 Author: Andrea Cosentino <anco...@gmail.com> Authored: Tue Jan 19 15:10:58 2016 +0100 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Tue Jan 19 15:10:58 2016 +0100 ---------------------------------------------------------------------- components/camel-nats/pom.xml | 5 ----- .../java/org/apache/camel/component/nats/NatsConsumer.java | 9 ++++++++- 2 files changed, 8 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/939a8951/components/camel-nats/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-nats/pom.xml b/components/camel-nats/pom.xml index f6130a9..e0da0c8 100644 --- a/components/camel-nats/pom.xml +++ b/components/camel-nats/pom.xml @@ -55,11 +55,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/camel/blob/939a8951/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java index 029ab13..c364277 100644 --- a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java +++ b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java @@ -63,7 +63,14 @@ public class NatsConsumer extends DefaultConsumer { protected void doStop() throws Exception { super.doStop(); - // TODO: Should we not unsubscribe first? + LOG.debug("Flushing Messages before stopping"); + connection.flush(); + + try { + connection.unsubscribe(sid); + } catch (Exception e) { + getExceptionHandler().handleException("Error during unsubscribing", e); + } LOG.debug("Stopping Nats Consumer"); if (executor != null) {