Package org.apache.camel.support
Class DefaultConsumer
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultConsumer
- All Implemented Interfaces:
AutoCloseable
,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.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, org.apache.camel.health.HealthCheckAware
A default consumer useful for implementation inheritance.
-
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
ConstructorsConstructorDescriptionDefaultConsumer
(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.camel.Exchange
createExchange
(boolean autoRelease) org.apache.camel.spi.UnitOfWork
createUoW
(org.apache.camel.Exchange exchange) If the consumer needs to defer done theUnitOfWork
on the processedExchange
then this method should be use to create and start theUnitOfWork
on the exchange.org.apache.camel.AsyncCallback
defaultConsumerCallback
(org.apache.camel.Exchange exchange, boolean autoRelease) protected void
doBuild()
protected void
doInit()
void
doneUoW
(org.apache.camel.Exchange exchange) If the consumer needs to defer done theUnitOfWork
on the processedExchange
then this method should be executed when the consumer is finished processing the message.protected void
protected void
doStart()
protected void
doStop()
org.apache.camel.AsyncProcessor
Provides anAsyncProcessor
interface to the configured processor on the consumer.org.apache.camel.Endpoint
org.apache.camel.spi.ExceptionHandler
org.apache.camel.health.HealthCheck
org.apache.camel.Processor
org.apache.camel.Route
getRoute()
protected void
handleException
(String message, Throwable t) Handles the given exception using thegetExceptionHandler()
protected void
handleException
(String message, org.apache.camel.Exchange exchange, Throwable t) Handles the given exception using thegetExceptionHandler()
protected void
Handles the given exception using thegetExceptionHandler()
void
releaseExchange
(org.apache.camel.Exchange exchange, boolean autoRelease) void
setExceptionHandler
(org.apache.camel.spi.ExceptionHandler exceptionHandler) void
setHealthCheck
(org.apache.camel.health.HealthCheck healthCheck) void
setRoute
(org.apache.camel.Route route) void
setRouteId
(String routeId) toString()
Methods inherited from class org.apache.camel.support.service.BaseService
build, doFail, doLifecycleChange, doResume, 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 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, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
DefaultConsumer
public DefaultConsumer(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor)
-
-
Method Details
-
toString
-
getRoute
public org.apache.camel.Route getRoute()- Specified by:
getRoute
in interfaceorg.apache.camel.RouteAware
-
setRoute
public void setRoute(org.apache.camel.Route route) - Specified by:
setRoute
in interfaceorg.apache.camel.RouteAware
-
getRouteId
- Specified by:
getRouteId
in interfaceorg.apache.camel.spi.RouteIdAware
-
setRouteId
- Specified by:
setRouteId
in interfaceorg.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 theUnitOfWork
on the processedExchange
then this method should be use to create and start theUnitOfWork
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
public void doneUoW(org.apache.camel.Exchange exchange) If the consumer needs to defer done theUnitOfWork
on the processedExchange
then this method should be executed when the consumer is finished processing the message.- Parameters:
exchange
- the exchange- See Also:
-
createExchange
public org.apache.camel.Exchange createExchange(boolean autoRelease) - Specified by:
createExchange
in interfaceorg.apache.camel.Consumer
-
releaseExchange
public void releaseExchange(org.apache.camel.Exchange exchange, boolean autoRelease) - Specified by:
releaseExchange
in interfaceorg.apache.camel.Consumer
-
defaultConsumerCallback
public org.apache.camel.AsyncCallback defaultConsumerCallback(org.apache.camel.Exchange exchange, boolean autoRelease) - Specified by:
defaultConsumerCallback
in interfaceorg.apache.camel.Consumer
-
getEndpoint
public org.apache.camel.Endpoint getEndpoint()- Specified by:
getEndpoint
in interfaceorg.apache.camel.EndpointAware
-
getProcessor
public org.apache.camel.Processor getProcessor()- Specified by:
getProcessor
in interfaceorg.apache.camel.Consumer
-
getAsyncProcessor
public org.apache.camel.AsyncProcessor getAsyncProcessor()Provides anAsyncProcessor
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) -
setHealthCheck
public void setHealthCheck(org.apache.camel.health.HealthCheck healthCheck) - Specified by:
setHealthCheck
in interfaceorg.apache.camel.health.HealthCheckAware
-
getHealthCheck
public org.apache.camel.health.HealthCheck getHealthCheck()- Specified by:
getHealthCheck
in interfaceorg.apache.camel.health.HealthCheckAware
-
doBuild
- Overrides:
doBuild
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doInit
- Overrides:
doInit
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doShutdown
- Overrides:
doShutdown
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
handleException
Handles the given exception using thegetExceptionHandler()
- Parameters:
t
- the exception to handle
-
handleException
Handles the given exception using thegetExceptionHandler()
- Parameters:
message
- additional message about the exceptiont
- the exception to handle
-
handleException
Handles the given exception using thegetExceptionHandler()
- Parameters:
message
- additional message about the exceptionexchange
- exchange which cause the exceptiont
- the exception to handle
-