org.apache.camel.processor
Class SendAsyncProcessor

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.processor.SendProcessor
          extended by org.apache.camel.processor.SendAsyncProcessor
All Implemented Interfaces:
Runnable, Navigate<Processor>, Processor, Traceable, Service

public class SendAsyncProcessor
extends SendProcessor
implements Runnable, Navigate<Processor>

Version:
$Revision: 889642 $

Field Summary
protected  BlockingQueue<Exchange> completedTasks
           
protected  ExceptionHandler exceptionHandler
           
protected  ExecutorService executorService
           
protected  int poolSize
           
protected  ExecutorService producerExecutorService
           
protected  Processor target
           
 
Fields inherited from class org.apache.camel.processor.SendProcessor
destination, LOG, pattern, producerCache
 
Constructor Summary
SendAsyncProcessor(Endpoint destination, ExchangePattern pattern, Processor target)
           
SendAsyncProcessor(Endpoint destination, Processor target)
           
 
Method Summary
protected  Exchange configureExchange(Exchange exchange, ExchangePattern pattern)
           
protected  ExecutorService createExecutorService(String name)
           
protected  void doAsyncProcess(AsyncProcessor producer, Exchange exchange, AsyncCallback callback)
          The producer is already capable of async processing so let it process it directly.
 Exchange doProcess(Exchange exchange)
          Strategy to process the exchange
protected  void doSimulateAsyncProcess(Processor producer, Exchange exchange, AsyncCallback callback)
          The producer is not capable of async processing so lets simulate this by transfering the task to another ExecutorService for async processing.
protected  void doStart()
           
protected  void doStop()
           
 ExceptionHandler getExceptionHandler()
           
 ExecutorService getExecutorService()
           
 int getPoolSize()
           
 ExecutorService getProducerExecutorService()
           
 boolean hasNext()
          Are there more outputs?
 List<Processor> next()
          Next group of outputs
 void run()
           
 void setExceptionHandler(ExceptionHandler exceptionHandler)
           
 void setExecutorService(ExecutorService executorService)
          Sets the ExecutorService to use for consuming replies.
 void setPoolSize(int poolSize)
           
 void setProducerExecutorService(ExecutorService producerExecutorService)
          Sets the ExecutorService to use for simulating async producers by transferring the Exchange to this ExecutorService for sending the request and block while waiting for the reply.
 String toString()
           
 
Methods inherited from class org.apache.camel.processor.SendProcessor
getDestination, getPattern, getProducerCache, getTraceLabel, process, setDestination
 
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

target

protected final Processor target

completedTasks

protected final BlockingQueue<Exchange> completedTasks

executorService

protected ExecutorService executorService

producerExecutorService

protected ExecutorService producerExecutorService

poolSize

protected int poolSize

exceptionHandler

protected ExceptionHandler exceptionHandler
Constructor Detail

SendAsyncProcessor

public SendAsyncProcessor(Endpoint destination,
                          Processor target)

SendAsyncProcessor

public SendAsyncProcessor(Endpoint destination,
                          ExchangePattern pattern,
                          Processor target)
Method Detail

configureExchange

protected Exchange configureExchange(Exchange exchange,
                                     ExchangePattern pattern)
Overrides:
configureExchange in class SendProcessor

doProcess

public Exchange doProcess(Exchange exchange)
                   throws Exception
Description copied from class: SendProcessor
Strategy to process the exchange

Overrides:
doProcess in class SendProcessor
Parameters:
exchange - the exchange
Returns:
the exchange that was processed
Throws:
Exception - can be thrown if error processing exchange

doAsyncProcess

protected void doAsyncProcess(AsyncProcessor producer,
                              Exchange exchange,
                              AsyncCallback callback)
                       throws Exception
The producer is already capable of async processing so let it process it directly.

Parameters:
producer - the async producer
exchange - the exchange
callback - the callback
Throws:
Exception - can be thrown in case of processing errors

doSimulateAsyncProcess

protected void doSimulateAsyncProcess(Processor producer,
                                      Exchange exchange,
                                      AsyncCallback callback)
                               throws Exception
The producer is not capable of async processing so lets simulate this by transfering the task to another ExecutorService for async processing.

Parameters:
producer - the producer
exchange - the exchange
callback - the callback
Throws:
Exception - can be thrown in case of processing errors

toString

public String toString()
Overrides:
toString in class SendProcessor

getExecutorService

public ExecutorService getExecutorService()

setExecutorService

public void setExecutorService(ExecutorService executorService)
Sets the ExecutorService to use for consuming replies.

Parameters:
executorService - the custom executor service

getProducerExecutorService

public ExecutorService getProducerExecutorService()

setProducerExecutorService

public void setProducerExecutorService(ExecutorService producerExecutorService)
Sets the ExecutorService to use for simulating async producers by transferring the Exchange to this ExecutorService for sending the request and block while waiting for the reply. However the original thread will not block and as such it all appears as real async request/reply mechanism.

Parameters:
producerExecutorService - the custom executor service for producers

getPoolSize

public int getPoolSize()

setPoolSize

public void setPoolSize(int poolSize)

getExceptionHandler

public ExceptionHandler getExceptionHandler()

setExceptionHandler

public void setExceptionHandler(ExceptionHandler exceptionHandler)

hasNext

public boolean hasNext()
Description copied from interface: Navigate
Are there more outputs?

Specified by:
hasNext in interface Navigate<Processor>
Returns:
true if more outputs

next

public List<Processor> next()
Description copied from interface: Navigate
Next group of outputs

Specified by:
next in interface Navigate<Processor>
Returns:
next group or null if no more outputs

run

public void run()
Specified by:
run in interface Runnable

createExecutorService

protected ExecutorService createExecutorService(String name)

doStart

protected void doStart()
                throws Exception
Overrides:
doStart in class SendProcessor
Throws:
Exception

doStop

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


Copyright © 2007-2010 The Apache Software Foundation. All Rights Reserved.