java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultConsumer
org.apache.camel.support.ScheduledPollConsumer
org.apache.camel.support.component.AbstractApiConsumer<E,T>
- All Implemented Interfaces:
AutoCloseable
,Runnable
,org.apache.camel.Consumer
,org.apache.camel.EndpointAware
,org.apache.camel.health.HealthCheckAware
,org.apache.camel.PollingConsumerPollingStrategy
,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.StatefulService
,PropertiesInterceptor
,PropertyNamesInterceptor
,ResultInterceptor
,org.apache.camel.Suspendable
,org.apache.camel.SuspendableService
public abstract class AbstractApiConsumer<E extends Enum<E> & ApiName,T>
extends ScheduledPollConsumer
implements PropertyNamesInterceptor, PropertiesInterceptor, ResultInterceptor
Abstract base class for API Component Consumers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AbstractApiEndpoint
<E, T> protected final ApiMethod
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
ConstructorsConstructorDescriptionAbstractApiConsumer
(AbstractApiEndpoint<E, T> endpoint, org.apache.camel.Processor processor) -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
doInvokeMethod
(Map<String, Object> args) Invoke the API method.void
interceptProperties
(Map<String, Object> properties) Intercept method invocation arguments used to find and invoke API method.void
interceptPropertyNames
(Set<String> propertyNames) Intercept property names used to find API Method.void
interceptResult
(Object result, org.apache.camel.Exchange resultExchange) Do additional result exchange processing, for example, adding custom headers.boolean
isGreedy()
final boolean
protected int
poll()
The polling method which is invoked periodically to poll this consumerfinal void
setSplitResult
(boolean splitResult) splitResult
(Object result) Split a complex result into result elements.Methods inherited from class org.apache.camel.support.ScheduledPollConsumer
addLastErrorDetail, afterConfigureScheduler, afterPoll, beforePoll, doBuild, doInit, doShutdown, doStart, doStop, doSuspend, forceConsumerAsReady, getBackoffCounter, getBackoffErrorThreshold, getBackoffIdleThreshold, getBackoffMultiplier, getCounter, getDelay, getErrorCounter, getInitialDelay, getLastError, getLastErrorDetails, getPollStrategy, getRepeatCount, getRunLoggingLevel, getScheduledExecutorService, getScheduler, getSchedulerProperties, getSuccessCounter, getTimeUnit, initialHealthCheckState, isConsumerReady, isFirstPollDone, isPollAllowed, isPolling, isSchedulerStarted, isSendEmptyMessageWhenIdle, isStartScheduler, isUseFixedDelay, onInit, processEmptyMessage, run, setBackoffErrorThreshold, setBackoffIdleThreshold, setBackoffMultiplier, setDelay, setGreedy, setInitialDelay, setPollStrategy, setRepeatCount, setRunLoggingLevel, setScheduledExecutorService, setScheduler, setSchedulerProperties, setSendEmptyMessageWhenIdle, setStartScheduler, setTimeUnit, setUseFixedDelay, startScheduler
Methods inherited from class org.apache.camel.support.DefaultConsumer
createExchange, createUoW, defaultConsumerCallback, doneUoW, getAsyncProcessor, getEndpoint, 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, doResume, fail, getInternalLock, 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.health.HealthCheckAware
getHealthCheck, setHealthCheck
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
-
Field Details
-
endpoint
-
method
-
-
Constructor Details
-
AbstractApiConsumer
-
-
Method Details
-
isGreedy
public boolean isGreedy()- Overrides:
isGreedy
in classScheduledPollConsumer
-
poll
Description copied from class:ScheduledPollConsumer
The polling method which is invoked periodically to poll this consumer- Specified by:
poll
in classScheduledPollConsumer
- Returns:
- number of messages polled, will be 0 if no message was polled at all.
- Throws:
Exception
- can be thrown if an exception occurred during polling
-
interceptPropertyNames
Description copied from interface:PropertyNamesInterceptor
Intercept property names used to find API Method. Used to add any custom/hidden method arguments, which MUST be provided in interceptProperties() override.- Specified by:
interceptPropertyNames
in interfacePropertyNamesInterceptor
- Parameters:
propertyNames
- argument names.
-
interceptProperties
Description copied from interface:PropertiesInterceptor
Intercept method invocation arguments used to find and invoke API method. Can be overridden to add custom/hidden method arguments.- Specified by:
interceptProperties
in interfacePropertiesInterceptor
- Parameters:
properties
- method invocation arguments.
-
doInvokeMethod
Invoke the API method. This method can be overridden, for example to synchronize API calls for thread-unsafe proxies. Derived class MUST call super.doInvokeMethod() to invoke the API method.- Parameters:
args
- method arguments from endpoint parameters.- Returns:
- method invocation result.
-
splitResult
Description copied from interface:ResultInterceptor
Split a complex result into result elements.- Specified by:
splitResult
in interfaceResultInterceptor
- Parameters:
result
- API method invocation result- Returns:
- either the same result if it cannot be split, an array or collection object with split results
-
interceptResult
Description copied from interface:ResultInterceptor
Do additional result exchange processing, for example, adding custom headers.- Specified by:
interceptResult
in interfaceResultInterceptor
- Parameters:
result
- result of API method invocation.resultExchange
- result as a Camel exchange, may be a split result from Arrays or Collections.
-
isSplitResult
public final boolean isSplitResult() -
setSplitResult
public final void setSplitResult(boolean splitResult)
-