org.apache.camel.impl
Class EventDrivenPollingConsumer
java.lang.Object
org.apache.camel.impl.ServiceSupport
org.apache.camel.impl.PollingConsumerSupport
org.apache.camel.impl.EventDrivenPollingConsumer
- All Implemented Interfaces:
- Consumer, PollingConsumer, Processor, Service, ShutdownableService
public class EventDrivenPollingConsumer
- extends PollingConsumerSupport
- 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:
Methods inherited from class org.apache.camel.impl.ServiceSupport |
addChildService, doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, start, stop, suspend |
EventDrivenPollingConsumer
public EventDrivenPollingConsumer(Endpoint endpoint)
EventDrivenPollingConsumer
public EventDrivenPollingConsumer(Endpoint endpoint,
BlockingQueue<Exchange> queue)
receiveNoWait
public Exchange 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
- Returns:
- the message exchange if one is immediately available otherwise
null
receive
public Exchange 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
- Returns:
- the message exchange received.
receive
public Exchange 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
- 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
- Parameters:
exchange
- the message exchange
- Throws:
Exception
- if an internal processing error has occurred.
getInterruptedExceptionHandler
public ExceptionHandler getInterruptedExceptionHandler()
setInterruptedExceptionHandler
public void setInterruptedExceptionHandler(ExceptionHandler interruptedExceptionHandler)
handleInterruptedException
protected void handleInterruptedException(InterruptedException e)
beforePoll
protected long beforePoll(long timeout)
afterPoll
protected void afterPoll()
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