Class SedaConsumer

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultConsumer
org.apache.camel.component.seda.SedaConsumer
All Implemented Interfaces:
AutoCloseable, Runnable, org.apache.camel.Consumer, org.apache.camel.EndpointAware, org.apache.camel.health.HealthCheckAware, org.apache.camel.RouteAware, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HostedService, 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

    Modifier and Type
    Method
    Description
    boolean
    deferShutdown(org.apache.camel.ShutdownRunningTask shutdownRunningTask)
     
    protected void
     
    protected void
     
    protected void
     
    protected void
     
    protected void
     
    protected void
     
     
    int
     
    boolean
     
    protected void
    onProcessingDone(org.apache.camel.Exchange original, org.apache.camel.Exchange prepared)
    Strategy to invoke when the exchange is done being processed.
    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, org.apache.camel.AsyncCallback callback)
    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, getHealthCheck, getProcessor, getRoute, getRouteId, handleException, handleException, handleException, isHostedService, releaseExchange, setExceptionHandler, setHealthCheck, setRoute, setRouteId, toString

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doFail, doLifecycleChange, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, 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.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 Details

    • SedaConsumer

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

    • 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()
    • onProcessingDone

      protected void onProcessingDone(org.apache.camel.Exchange original, org.apache.camel.Exchange prepared)
      Strategy to invoke when the exchange is done being processed.

      This method is meant to be overridden by subclasses to be able to mimic the behavior of the legacy component camel-vm, that is why the parameter prepared is not used by default.

      Parameters:
      original - the exchange before being processed
      prepared - the exchange processed
    • prepareExchange

      protected org.apache.camel.Exchange prepareExchange(org.apache.camel.Exchange exchange)
      Strategy to prepare exchange for being processed by this consumer

      This method is meant to be overridden by subclasses to be able to mimic the behavior of the legacy component camel-vm, that is why the prepared exchange is returned.

      Parameters:
      exchange - the exchange
      Returns:
      the exchange to process by this consumer
    • sendToConsumers

      protected void sendToConsumers(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback) 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
      callback - exchange callback to continue routing
      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