org.apache.camel.processor
Class ThreadsProcessor

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.processor.DelegateProcessor
          extended by org.apache.camel.processor.ThreadsProcessor
All Implemented Interfaces:
Navigate, Processor, Service

public class ThreadsProcessor
extends DelegateProcessor
implements Processor

Threads processor that leverage a thread pool for processing exchanges.

The original caller thread will receive a Future<Exchange> in the OUT message body. It can then later use this handle to obtain the async response.

Camel also provides type converters so you can just ask to get the desired object type and Camel will automatic wait for the async task to complete to return the response.

Version:
$Revision: 780262 $

Field Summary
protected static int DEFAULT_THREADPOOL_SIZE
           
protected  ExecutorService executorService
           
protected  WaitForTaskToComplete waitForTaskToComplete
           
 
Fields inherited from class org.apache.camel.processor.DelegateProcessor
processor
 
Constructor Summary
ThreadsProcessor(Processor output, ExecutorService executorService, WaitForTaskToComplete waitForTaskToComplete)
           
 
Method Summary
protected  ExecutorService createExecutorService()
           
protected  Callable<Exchange> createTask(Processor output, Exchange copy)
           
protected  void doStop()
           
 ExecutorService getExecutorService()
           
 void process(Exchange exchange)
          Processes the message exchange
 
Methods inherited from class org.apache.camel.processor.DelegateProcessor
doStart, getProcessor, hasNext, next, proceed, processNext, setProcessor, toString
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, removeChildService, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_THREADPOOL_SIZE

protected static final int DEFAULT_THREADPOOL_SIZE
See Also:
Constant Field Values

executorService

protected ExecutorService executorService

waitForTaskToComplete

protected WaitForTaskToComplete waitForTaskToComplete
Constructor Detail

ThreadsProcessor

public ThreadsProcessor(Processor output,
                        ExecutorService executorService,
                        WaitForTaskToComplete waitForTaskToComplete)
Method Detail

process

public void process(Exchange exchange)
             throws Exception
Description copied from interface: Processor
Processes the message exchange

Specified by:
process in interface Processor
Overrides:
process in class DelegateProcessor
Parameters:
exchange - the message exchange
Throws:
Exception - if an internal processing error has occurred.

createTask

protected Callable<Exchange> createTask(Processor output,
                                        Exchange copy)

getExecutorService

public ExecutorService getExecutorService()

createExecutorService

protected ExecutorService createExecutorService()

doStop

protected void doStop()
               throws Exception
Overrides:
doStop in class DelegateProcessor
Throws:
Exception


Copyright © 2009 Apache Software Foundation. All Rights Reserved.