org.apache.camel.impl
Class EventDrivenPollingConsumer<E extends Exchange>

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.impl.PollingConsumerSupport<E>
          extended by org.apache.camel.impl.EventDrivenPollingConsumer<E>
All Implemented Interfaces:
Consumer<E>, PollingConsumer<E>, Processor, Service

public class EventDrivenPollingConsumer<E extends Exchange>
extends PollingConsumerSupport<E>
implements Processor

A default implementation of the PollingConsumer which uses the normal asynchronous consumer mechanism along with a BlockingQueue to allow the caller to pull messages on demand.

Version:
$Revision: 706523 $

Constructor Summary
EventDrivenPollingConsumer(Endpoint<E> endpoint)
           
EventDrivenPollingConsumer(Endpoint<E> endpoint, BlockingQueue<E> queue)
           
 
Method Summary
protected  void doStart()
           
protected  void doStop()
           
 ExceptionHandler getInteruptedExceptionHandler()
           
protected  void handleInteruptedException(InterruptedException e)
           
 void process(Exchange exchange)
          Processes the message exchange
 E receive()
          Waits until a message is available and then returns it.
 E receive(long timeout)
          Attempts to receive a message exchange, waiting up to the given timeout to expire if a message is not yet available
 E receiveNoWait()
          Attempts to receive a message exchange immediately without waiting and returning null if a message exchange is not available yet.
 void setInteruptedExceptionHandler(ExceptionHandler interuptedExceptionHandler)
           
 
Methods inherited from class org.apache.camel.impl.PollingConsumerSupport
getEndpoint, getExceptionHandler, handleException, setExceptionHandler, toString
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, getThreadName, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, nextThreadCounter, removeChildService, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.Service
start, stop
 

Constructor Detail

EventDrivenPollingConsumer

public EventDrivenPollingConsumer(Endpoint<E> endpoint)

EventDrivenPollingConsumer

public EventDrivenPollingConsumer(Endpoint<E> endpoint,
                                  BlockingQueue<E> queue)
Method Detail

receiveNoWait

public E receiveNoWait()
Description copied from interface: PollingConsumer
Attempts to receive a message exchange immediately without waiting and returning null if a message exchange is not available yet.

Specified by:
receiveNoWait in interface PollingConsumer<E extends Exchange>
Returns:
the message exchange if one is immediately available otherwise null

receive

public E receive()
Description copied from interface: PollingConsumer
Waits until a message is available and then returns it. Warning that this method could block indefinitely if no messages are available.

Will return null if the consumer is not started

Specified by:
receive in interface PollingConsumer<E extends Exchange>
Returns:
the message exchange received.

receive

public E receive(long timeout)
Description copied from interface: PollingConsumer
Attempts to receive a message exchange, waiting up to the given timeout to expire if a message is not yet available

Specified by:
receive in interface PollingConsumer<E extends Exchange>
Parameters:
timeout - the amount of time in milliseconds to wait for a message before timing out and returning null
Returns:
the message exchange if one iwas available within the timeout period, or null if the timeout expired

process

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

Specified by:
process in interface Processor
Throws:
Exception - if an internal processing error has occurred.

getInteruptedExceptionHandler

public ExceptionHandler getInteruptedExceptionHandler()

setInteruptedExceptionHandler

public void setInteruptedExceptionHandler(ExceptionHandler interuptedExceptionHandler)

handleInteruptedException

protected void handleInteruptedException(InterruptedException e)

doStart

protected void doStart()
                throws Exception
Specified by:
doStart in class ServiceSupport
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class ServiceSupport
Throws:
Exception


Apache CAMEL