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 ApiMethodFields 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 ObjectdoInvokeMethod(Map<String, Object> args) Invoke the API method.voidinterceptProperties(Map<String, Object> properties) Intercept method invocation arguments used to find and invoke API method.voidinterceptPropertyNames(Set<String> propertyNames) Intercept property names used to find API Method.voidinterceptResult(Object result, org.apache.camel.Exchange resultExchange) Do additional result exchange processing, for example, adding custom headers.booleanisGreedy()final booleanprotected intpoll()The polling method which is invoked periodically to poll this consumerfinal voidsetSplitResult(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, poll, processEmptyMessage, run, setBackoffErrorThreshold, setBackoffIdleThreshold, setBackoffMultiplier, setDelay, setGreedy, setInitialDelay, setPollStrategy, setRepeatCount, setRunLoggingLevel, setScheduledExecutorService, setScheduler, setSchedulerProperties, setSendEmptyMessageWhenIdle, setStartScheduler, setTimeUnit, setUseFixedDelay, startSchedulerMethods 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, toStringMethods 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, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.camel.health.HealthCheckAware
getHealthCheck, setHealthCheckMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
endpoint
-
method
-
-
Constructor Details
-
AbstractApiConsumer
-
-
Method Details
-
isGreedy
public boolean isGreedy()- Overrides:
isGreedyin classScheduledPollConsumer
-
poll
Description copied from class:ScheduledPollConsumerThe polling method which is invoked periodically to poll this consumer- Specified by:
pollin 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:PropertyNamesInterceptorIntercept property names used to find API Method. Used to add any custom/hidden method arguments, which MUST be provided in interceptProperties() override.- Specified by:
interceptPropertyNamesin interfacePropertyNamesInterceptor- Parameters:
propertyNames- argument names.
-
interceptProperties
Description copied from interface:PropertiesInterceptorIntercept method invocation arguments used to find and invoke API method. Can be overridden to add custom/hidden method arguments.- Specified by:
interceptPropertiesin 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:ResultInterceptorSplit a complex result into result elements.- Specified by:
splitResultin 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:ResultInterceptorDo additional result exchange processing, for example, adding custom headers.- Specified by:
interceptResultin 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)
-