You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jorge Davison <jd...@gmail.com> on 2012/08/31 17:43:52 UTC
Blocking Processor Issue
Hi all, currently i trying to create a blocking processor. This is a
processor that block the threads until a condition is raised. To make this
processor i'm using a Semaphore that acquire when processed a Exchange and
a Timer that execute every X second that release this semaphore to let pass
the blocked threads. This solution work like a charm but the problem
appears when the Camel context is shutting down. In this moment i need to
release all blocked threads, for this, i need that Camel call a shutdown
method.
To implement this the processor extends ServiceSupport class but i can't
get it work.
public void process(Exchange exchange) throws Exception {
semaphore.acquire();
}
protected void doStop() throws Exception {
if (semaphore.hasQueuedThreads()) {
int queueLength = semaphore.getQueueLength();
semaphore.release(queueLength);
}
}
Any suggestions?
--
Jorge Davison
Re: Blocking Processor Issue
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Camel 2.10 onwards have a org.apache.camel.spi.ShutdownPrepared your
custom processor can implement, and get notification when shutdown is
in progress.
On Fri, Aug 31, 2012 at 5:43 PM, Jorge Davison <jd...@gmail.com> wrote:
> Hi all, currently i trying to create a blocking processor. This is a
> processor that block the threads until a condition is raised. To make this
> processor i'm using a Semaphore that acquire when processed a Exchange and
> a Timer that execute every X second that release this semaphore to let pass
> the blocked threads. This solution work like a charm but the problem
> appears when the Camel context is shutting down. In this moment i need to
> release all blocked threads, for this, i need that Camel call a shutdown
> method.
> To implement this the processor extends ServiceSupport class but i can't
> get it work.
>
> public void process(Exchange exchange) throws Exception {
> semaphore.acquire();
> }
>
> protected void doStop() throws Exception {
> if (semaphore.hasQueuedThreads()) {
> int queueLength = semaphore.getQueueLength();
> semaphore.release(queueLength);
> }
> }
>
> Any suggestions?
>
>
> --
> Jorge Davison
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen