camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Zhemzhitsky (Issue Comment Edited) (JIRA)" <j...@apache.org>
Subject [jira] [Issue Comment Edited] (CAMEL-4925) ThreadsProcessor configured with ExecutorService with DiscardPolicy or DiscardOldestPolicy leaves inflight exchanges for discarded tasks unprocessed.
Date Sun, 22 Jan 2012 18:56:39 GMT

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

Sergey Zhemzhitsky edited comment on CAMEL-4925 at 1/22/12 6:54 PM:
--------------------------------------------------------------------

Claus, thanks a lot.

I've done some experiments with the blocking policy that seems rather dangerous, as threads
in the pool may become timed out before the rejected task will be put into the queue. So you're
right that this policy has to be removed.
                
      was (Author: szhemzhitsky):
    Claus, thanks a lot.

If you don't mind I will create a new jira improvement to add a blocked policy. It's not more
dangerous than CallerRuns strategy, which also may block the main thread forever (for example
when all the threads in the pool are busy, the working queue is full and the next submitted
task is never-ending). Also once the main thread is executing the task no one be able to submit
new tasks with CallerRuns strategy.
                  
> ThreadsProcessor configured with ExecutorService with DiscardPolicy or DiscardOldestPolicy
leaves inflight exchanges for discarded tasks unprocessed.
> -----------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-4925
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4925
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.0
>            Reporter: Sergey Zhemzhitsky
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.10.0
>
>         Attachments: CAMEL-4925.patch, CamelRoutingTest.java
>
>
> ThreadsProcessor configured with ExecutorService with DiscardPolicy or DiscardOldestPolicy
leaves inflight exchanges for discarded tasks unprocessed.
> Here is the code from ThreadsProcessor. In case of DiscardPolicy or DiscardOldestPolicy
executorService will no throw RejectedExecutionException, so exchange remains unprocessed
and count of inflight exchanges will not be decremented for such discarded exchanges.
> {code:java|title=ThreadsProcessor#process(Exchange, AsyncCallback)}
> public boolean process(Exchange exchange, AsyncCallback callback) {
>     if (shutdown.get()) {
>         throw new IllegalStateException("ThreadsProcessor is not running.");
>     }
>     ProcessCall call = new ProcessCall(exchange, callback);
>     try {
>         executorService.submit(call);
>         // tell Camel routing engine we continue routing asynchronous
>         return false;
>     } catch (RejectedExecutionException e) {
>         if (isCallerRunsWhenRejected()) {
>             if (shutdown.get()) {
>                 exchange.setException(new RejectedExecutionException());
>             } else {
>                 callback.done(true);
>             }
>         } else {
>             exchange.setException(e);
>         }
>         return true;
>     }
> }
> {code}
> Unit test is attached.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message