org.apache.camel.component.mail
Class MailConsumer

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.impl.DefaultConsumer
          extended by org.apache.camel.impl.ScheduledPollConsumer
              extended by org.apache.camel.component.mail.MailConsumer
All Implemented Interfaces:
Runnable, BatchConsumer, Consumer, Service, ShutdownableService, ShutdownAware, SuspendableService

public class MailConsumer
extends ScheduledPollConsumer
implements BatchConsumer, ShutdownAware

A Consumer which consumes messages from JavaMail using a Transport and dispatches them to the Processor

Version:
$Revision: 980707 $

Field Summary
static long DEFAULT_CONSUMER_DELAY
           
 
Fields inherited from class org.apache.camel.impl.DefaultConsumer
log
 
Constructor Summary
MailConsumer(MailEndpoint endpoint, Processor processor, JavaMailSenderImpl sender)
           
 
Method Summary
protected  Queue<Exchange> createExchanges(Message[] messages)
           
 boolean deferShutdown(ShutdownRunningTask shutdownRunningTask)
           
protected  void doStart()
           
protected  void doStop()
           
 int getPendingExchangesSize()
           
 boolean isBatchAllowed()
           
protected  void poll()
           
 void processBatch(Queue<Object> exchanges)
           
protected  void processCommit(Message mail, Exchange exchange)
          Strategy to flag the message after being processed.
protected  void processExchange(Exchange exchange)
          Strategy to process the mail message.
protected  void processRollback(Message mail, Exchange exchange)
          Strategy when processing the exchange failed.
 void setMaxMessagesPerPoll(int maxMessagesPerPoll)
           
 
Methods inherited from class org.apache.camel.impl.ScheduledPollConsumer
doSuspend, getDelay, getInitialDelay, getPollStrategy, getTimeUnit, isPollAllowed, isUseFixedDelay, run, setDelay, setInitialDelay, setPollStrategy, setTimeUnit, setUseFixedDelay
 
Methods inherited from class org.apache.camel.impl.DefaultConsumer
getAsyncProcessor, getEndpoint, getExceptionHandler, getProcessor, handleException, setExceptionHandler, toString
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, doResume, doShutdown, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.Consumer
getEndpoint
 
Methods inherited from interface org.apache.camel.Service
start, stop
 
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
 

Field Detail

DEFAULT_CONSUMER_DELAY

public static final long DEFAULT_CONSUMER_DELAY
See Also:
Constant Field Values
Constructor Detail

MailConsumer

public MailConsumer(MailEndpoint endpoint,
                    Processor processor,
                    JavaMailSenderImpl sender)
Method Detail

doStart

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

doStop

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

poll

protected void poll()
             throws Exception
Specified by:
poll in class ScheduledPollConsumer
Throws:
Exception

setMaxMessagesPerPoll

public void setMaxMessagesPerPoll(int maxMessagesPerPoll)
Specified by:
setMaxMessagesPerPoll in interface BatchConsumer

processBatch

public void processBatch(Queue<Object> exchanges)
                  throws Exception
Specified by:
processBatch in interface BatchConsumer
Throws:
Exception

deferShutdown

public boolean deferShutdown(ShutdownRunningTask shutdownRunningTask)
Specified by:
deferShutdown in interface ShutdownAware

getPendingExchangesSize

public int getPendingExchangesSize()
Specified by:
getPendingExchangesSize in interface ShutdownAware

isBatchAllowed

public boolean isBatchAllowed()
Specified by:
isBatchAllowed in interface BatchConsumer

createExchanges

protected Queue<Exchange> createExchanges(Message[] messages)
                                   throws MessagingException
Throws:
MessagingException

processExchange

protected void processExchange(Exchange exchange)
                        throws Exception
Strategy to process the mail message.

Throws:
Exception

processCommit

protected void processCommit(Message mail,
                             Exchange exchange)
Strategy to flag the message after being processed.

Parameters:
mail - the mail message
exchange - the exchange

processRollback

protected void processRollback(Message mail,
                               Exchange exchange)
Strategy when processing the exchange failed.

Parameters:
mail - the mail message
exchange - the exchange


Apache CAMEL