Class DefaultConsumer

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.Consumer, org.apache.camel.EndpointAware, org.apache.camel.RouteAware, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.RouteIdAware, org.apache.camel.StatefulService, org.apache.camel.SuspendableService
    Direct Known Subclasses:
    ScheduledPollConsumer

    public class DefaultConsumer
    extends org.apache.camel.support.service.ServiceSupport
    implements org.apache.camel.Consumer, org.apache.camel.RouteAware, org.apache.camel.spi.RouteIdAware
    A default consumer useful for implementation inheritance.
    • Field Summary

      • Fields inherited from class org.apache.camel.support.service.BaseService

        BUILDED, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTINGDOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultConsumer​(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.camel.spi.UnitOfWork createUoW​(org.apache.camel.Exchange exchange)
      If the consumer needs to defer done the UnitOfWork on the processed Exchange then this method should be use to create and start the UnitOfWork on the exchange.
      protected void doInit()  
      void doneUoW​(org.apache.camel.Exchange exchange)
      If the consumer needs to defer done the UnitOfWork on the processed Exchange then this method should be executed when the consumer is finished processing the message.
      protected void doStart()  
      protected void doStop()  
      org.apache.camel.AsyncProcessor getAsyncProcessor()
      Provides an AsyncProcessor interface to the configured processor on the consumer.
      org.apache.camel.Endpoint getEndpoint()  
      org.apache.camel.spi.ExceptionHandler getExceptionHandler()  
      org.apache.camel.Processor getProcessor()  
      org.apache.camel.Route getRoute()  
      String getRouteId()  
      protected void handleException​(String message, Throwable t)
      Handles the given exception using the getExceptionHandler()
      protected void handleException​(Throwable t)
      Handles the given exception using the getExceptionHandler()
      void setExceptionHandler​(org.apache.camel.spi.ExceptionHandler exceptionHandler)  
      void setRoute​(org.apache.camel.Route route)  
      void setRouteId​(String routeId)  
      String toString()  
      • Methods inherited from class org.apache.camel.support.service.BaseService

        build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
      • Methods inherited from interface org.apache.camel.Service

        build, close, init, start, stop
      • Methods inherited from interface org.apache.camel.ShutdownableService

        shutdown
      • Methods inherited from interface org.apache.camel.StatefulService

        getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
      • Methods inherited from interface org.apache.camel.SuspendableService

        isSuspended, resume, suspend
    • Constructor Detail

      • DefaultConsumer

        public DefaultConsumer​(org.apache.camel.Endpoint endpoint,
                               org.apache.camel.Processor processor)
    • Method Detail

      • getRoute

        public org.apache.camel.Route getRoute()
        Specified by:
        getRoute in interface org.apache.camel.RouteAware
      • setRoute

        public void setRoute​(org.apache.camel.Route route)
        Specified by:
        setRoute in interface org.apache.camel.RouteAware
      • getRouteId

        public String getRouteId()
        Specified by:
        getRouteId in interface org.apache.camel.spi.RouteIdAware
      • setRouteId

        public void setRouteId​(String routeId)
        Specified by:
        setRouteId in interface org.apache.camel.spi.RouteIdAware
      • createUoW

        public org.apache.camel.spi.UnitOfWork createUoW​(org.apache.camel.Exchange exchange)
                                                  throws Exception
        If the consumer needs to defer done the UnitOfWork on the processed Exchange then this method should be use to create and start the UnitOfWork on the exchange.
        Parameters:
        exchange - the exchange
        Returns:
        the created and started unit of work
        Throws:
        Exception - is thrown if error starting the unit of work
        See Also:
        doneUoW(org.apache.camel.Exchange)
      • doneUoW

        public void doneUoW​(org.apache.camel.Exchange exchange)
        If the consumer needs to defer done the UnitOfWork on the processed Exchange then this method should be executed when the consumer is finished processing the message.
        Parameters:
        exchange - the exchange
        See Also:
        createUoW(org.apache.camel.Exchange)
      • getEndpoint

        public org.apache.camel.Endpoint getEndpoint()
        Specified by:
        getEndpoint in interface org.apache.camel.EndpointAware
      • getProcessor

        public org.apache.camel.Processor getProcessor()
        Specified by:
        getProcessor in interface org.apache.camel.Consumer
      • getAsyncProcessor

        public org.apache.camel.AsyncProcessor getAsyncProcessor()
        Provides an AsyncProcessor interface to the configured processor on the consumer. If the processor does not implement the interface, it will be adapted so that it does.
      • getExceptionHandler

        public org.apache.camel.spi.ExceptionHandler getExceptionHandler()
      • setExceptionHandler

        public void setExceptionHandler​(org.apache.camel.spi.ExceptionHandler exceptionHandler)
      • doInit

        protected void doInit()
                       throws Exception
        Overrides:
        doInit in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doStart

        protected void doStart()
                        throws Exception
        Overrides:
        doStart in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • handleException

        protected void handleException​(Throwable t)
        Handles the given exception using the getExceptionHandler()
        Parameters:
        t - the exception to handle
      • handleException

        protected void handleException​(String message,
                                       Throwable t)
        Handles the given exception using the getExceptionHandler()
        Parameters:
        message - additional message about the exception
        t - the exception to handle