-
2. Re: FTP Consumer Template thread problem.
sekaijin Apr 22, 2013 4:28 AM (in response to davsclaus)thank for this response but
My problem comes with a consumer template and not a producer template.
My problem is not to create a "multi thread" consumer template .
my processor code is
public void process(Exchange exchange) throws Exception {
...
ConsumerTemplate con = exchange.getContext().createConsumerTemplate();
//retrive the file associated with message
//one thread is created, and one EndPoint is created
exTdd = con.receive(urlFinal"fileName="name, TIME_OUT);
if (null != exTdd) {
//enrich the current exchange with the downloaded file
*... *
//I'm not sure con.doneUoW(exchange); or con.doneUoW(exTdd);
con.doneUoW(exchange);
}
//stop the consummer template
con.stop();
//remove the endpoint
exchange.getContext().removeEndpoints((urlFinal"fileName="name)*
// the endpoint is deleted. but the thread remains
}
Bye
-
3. Re: FTP Consumer Template thread problem.
davsclaus Apr 22, 2013 2:24 PM (in response to sekaijin)The same idea applies for consumer template. Create it once, and keep it around. And stop it when you stop your app.
-
4. Re: FTP Consumer Template thread problem.
sekaijin Apr 26, 2013 6:51 AM (in response to davsclaus)thank but
I can't stop and restart my application every time I get a message. of thousand times a day.
I created A single template in my context. forevery message I get, I must create a different endpoint, my url depend on the content of the message.
I create a different endpoint, so a thread every time. I stop the endpoint and removes it after I received the content. but the thread is still not released.
public void process(Exchange exchange) throws Exception {
...
ConsumerTemplate con = getStaticConsumerTemplate();
//retrive the file associated with message
//one thread is created, and one EndPoint is created
exTdd = con.receive(urlFinal"fileName="name, TIME_OUT);
if (null != exTdd) {
//enrich the current exchange with the downloaded file
...
//I'm not sure con.doneUoW(exchange); or con.doneUoW(exTdd);
con.doneUoW(exchange);
}
//stop the consummer template
con.stop();
//remove the endpoint
exchange.getContext().removeEndpoints(urlFinal"fileName="name)
// the endpoint is deleted. but the thread remains
}
I've always creates a thread per message received and the JVM crashes because it exceed the cota of thread per process, supported by the OS.