You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by edvicif <ed...@gmail.com> on 2012/12/03 18:19:59 UTC

Thread leak when create pollEnrich

Hi!

I have a solution, that I want to receive files from various places. The
file I need to download I receive as a message.

To achieve this I'm using pollEnrich. But because the path cannot be
configured dynamically for every file I create a new route, where the
pollEnrich instance points different paths.

When the enrich fetch the file onComplition it stops the route and removes
it from the context.

      camelContext.getInflightRepository().remove(exchange);
      camelContext.stopRoute(routeId);
      camelContext.removeRoute(routeId);

It works fine, but when I monitor the logs I see the thread id numbers are
increasing and if we let the service run for a long time, we receive memory
out of exception as we cannot request more threads.

How can I remove my route so it free up the threads.

Or I saw this new functions scheduledExecutorService. I was thinking that if
I sign if route to the same threadpool it prevents the thread generation.

But I cannot reference threadpools. When I pass it to the file options I
receive:

java.lang.IllegalArgumentException: Could not find a suitable setter for
property: scheduledExecutorService as there isn't a setter method with same
type: java.lang.String nor type conversion possible: No type converter
available to convert from type: java.lang.String to the required type:
java.util.concurrent.ScheduledExecutorService with value testPool

Can you help me with this?



--
View this message in context: http://camel.465427.n5.nabble.com/Thread-leak-when-create-pollEnrich-tp5723554.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Thread leak when create pollEnrich

Posted by edvicif <ed...@gmail.com>.
The problem is that I'm consuming through sftp.

My problem is that I see that the thread count is increasing with the
template and the dynamic routing solution.

As the unused endpoint after it consumed the file not free up. I've
experienced this with the consumer template as well.

Is there a way to reuse sftp endpoint, which on incoming filenames using the
same connection or at least the same endpoint downloads the same file.

Or assign the endpoint to the same threadpool would be also nice.



--
View this message in context: http://camel.465427.n5.nabble.com/Thread-leak-when-create-pollEnrich-tp5723554p5723602.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Thread leak when create pollEnrich

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

If all you need to pickup a file, (and no need to delete/move it
afterwards etc) you can just use a java bean, to set the message body
to a java.io.File handle for the file.

public static pickupFile(@Header("myFileName") String name) {
  return new java.io.File(name);
}

Though you can also use a java bean with a consumer template, and
re-use that template to consume from uris you can compute in the java
bean.
Then you don't need to add/remove routes, which is a bit overkill.



On Mon, Dec 3, 2012 at 6:19 PM, edvicif <ed...@gmail.com> wrote:
> Hi!
>
> I have a solution, that I want to receive files from various places. The
> file I need to download I receive as a message.
>
> To achieve this I'm using pollEnrich. But because the path cannot be
> configured dynamically for every file I create a new route, where the
> pollEnrich instance points different paths.
>
> When the enrich fetch the file onComplition it stops the route and removes
> it from the context.
>
>       camelContext.getInflightRepository().remove(exchange);
>       camelContext.stopRoute(routeId);
>       camelContext.removeRoute(routeId);
>
> It works fine, but when I monitor the logs I see the thread id numbers are
> increasing and if we let the service run for a long time, we receive memory
> out of exception as we cannot request more threads.
>
> How can I remove my route so it free up the threads.
>
> Or I saw this new functions scheduledExecutorService. I was thinking that if
> I sign if route to the same threadpool it prevents the thread generation.
>
> But I cannot reference threadpools. When I pass it to the file options I
> receive:
>
> java.lang.IllegalArgumentException: Could not find a suitable setter for
> property: scheduledExecutorService as there isn't a setter method with same
> type: java.lang.String nor type conversion possible: No type converter
> available to convert from type: java.lang.String to the required type:
> java.util.concurrent.ScheduledExecutorService with value testPool
>
> Can you help me with this?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Thread-leak-when-create-pollEnrich-tp5723554.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen