You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Jonathan Anstey (JIRA)" <ji...@apache.org> on 2012/10/02 22:17:08 UTC

[jira] [Commented] (CAMEL-5677) Stopping and starting a seda consumer leaks a thread each time

    [ https://issues.apache.org/jira/browse/CAMEL-5677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13468036#comment-13468036 ] 

Jonathan Anstey commented on CAMEL-5677:
----------------------------------------

Running tests on this solution now:

{code}
[janstey@duffman camel-core (trunk)]$ git diff
diff --git a/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java b/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
index a21ab36..cbe23ac 100644
--- a/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
@@ -300,6 +300,13 @@ public class SedaConsumer extends ServiceSupport implements Consumer, Runnable,
 
     protected void doStop() throws Exception {
         endpoint.onStopped(this);
+        
+        // need to shutdown executor here as well or each time this endpoint is 
+        // started a new thread will be created
+        if (executor != null) {
+            endpoint.getCamelContext().getExecutorServiceManager().shutdownNow(executor);
+            executor = null;
+        }
     }
 
     @Override
{code}
                
> Stopping and starting a seda consumer leaks a thread each time
> --------------------------------------------------------------
>
>                 Key: CAMEL-5677
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5677
>             Project: Camel
>          Issue Type: Bug
>            Reporter: Jonathan Anstey
>            Assignee: Jonathan Anstey
>
> Just did something like this:
>         for (int i = 0; i < 1000; i++) {
>             context.stopRoute("sedaToMock");
>             context.startRoute("sedaToMock");	        
>         }      
> and yeah, I had over 1000 threads in my JVM... not good :)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira