Class SedaConsumer

  • All Implemented Interfaces:
    AutoCloseable, Runnable, 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.spi.ShutdownAware, org.apache.camel.spi.ShutdownPrepared, org.apache.camel.StatefulService, org.apache.camel.Suspendable, org.apache.camel.SuspendableService

    public class SedaConsumer
    extends org.apache.camel.support.DefaultConsumer
    implements Runnable, org.apache.camel.spi.ShutdownAware, org.apache.camel.Suspendable
    A Consumer for the SEDA component.

    In this implementation there is a little slack period when you suspend/stop the consumer, by which the consumer may pickup a newly arrived messages and process it. That period is up till 1 second.

    • Field Summary

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

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

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean deferShutdown​(org.apache.camel.ShutdownRunningTask shutdownRunningTask)  
      protected void doResume()  
      protected void doRun()  
      protected void doShutdown()  
      protected void doStart()  
      protected void doStop()  
      protected void doSuspend()  
      SedaEndpoint getEndpoint()  
      int getPendingExchangesSize()  
      boolean isRunAllowed()  
      protected org.apache.camel.Exchange prepareExchange​(org.apache.camel.Exchange exchange)
      Strategy to prepare exchange for being processed by this consumer
      void prepareShutdown​(boolean suspendOnly, boolean forced)  
      void run()  
      protected void sendToConsumers​(org.apache.camel.Exchange exchange)
      Send the given Exchange to the consumer(s).
      • Methods inherited from class org.apache.camel.support.DefaultConsumer

        createExchange, createUoW, defaultConsumerCallback, doBuild, doInit, doneUoW, getAsyncProcessor, getExceptionHandler, getProcessor, getRoute, getRouteId, handleException, handleException, releaseExchange, setExceptionHandler, setRoute, setRouteId, toString
      • Methods inherited from class org.apache.camel.support.service.BaseService

        build, doFail, doLifecycleChange, fail, getStatus, init, isBuild, isInit, isNew, 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, isStarted, isStarting, isStopped, isStopping, isSuspending
      • Methods inherited from interface org.apache.camel.SuspendableService

        isSuspended, resume, suspend
    • Constructor Detail

      • SedaConsumer

        public SedaConsumer​(SedaEndpoint endpoint,
                            org.apache.camel.Processor processor)
    • Method Detail

      • getEndpoint

        public SedaEndpoint getEndpoint()
        Specified by:
        getEndpoint in interface org.apache.camel.EndpointAware
        Overrides:
        getEndpoint in class org.apache.camel.support.DefaultConsumer
      • deferShutdown

        public boolean deferShutdown​(org.apache.camel.ShutdownRunningTask shutdownRunningTask)
        Specified by:
        deferShutdown in interface org.apache.camel.spi.ShutdownAware
      • getPendingExchangesSize

        public int getPendingExchangesSize()
        Specified by:
        getPendingExchangesSize in interface org.apache.camel.spi.ShutdownAware
      • prepareShutdown

        public void prepareShutdown​(boolean suspendOnly,
                                    boolean forced)
        Specified by:
        prepareShutdown in interface org.apache.camel.spi.ShutdownPrepared
      • isRunAllowed

        public boolean isRunAllowed()
        Specified by:
        isRunAllowed in interface org.apache.camel.StatefulService
        Overrides:
        isRunAllowed in class org.apache.camel.support.service.BaseService
      • run

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

        protected void doRun()
      • prepareExchange

        protected org.apache.camel.Exchange prepareExchange​(org.apache.camel.Exchange exchange)
        Strategy to prepare exchange for being processed by this consumer
        Parameters:
        exchange - the exchange
        Returns:
        the exchange to process by this consumer.
      • sendToConsumers

        protected void sendToConsumers​(org.apache.camel.Exchange exchange)
                                throws Exception
        Send the given Exchange to the consumer(s).

        If multiple consumers then they will each receive a copy of the Exchange. A multicast processor will send the exchange in parallel to the multiple consumers.

        If there is only a single consumer then its dispatched directly to it using same thread.

        Parameters:
        exchange - the exchange
        Throws:
        Exception - can be thrown if processing of the exchange failed
      • doStart

        protected void doStart()
                        throws Exception
        Overrides:
        doStart in class org.apache.camel.support.DefaultConsumer
        Throws:
        Exception
      • doSuspend

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

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

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.DefaultConsumer
        Throws:
        Exception
      • doShutdown

        protected void doShutdown()
                           throws Exception
        Overrides:
        doShutdown in class org.apache.camel.support.DefaultConsumer
        Throws:
        Exception