- 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.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.
-
-
Constructor Summary
Constructors Constructor Description AbstractApiConsumer(AbstractApiEndpoint<E,T> endpoint, org.apache.camel.Processor processor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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()
boolean
isSplitResult()
protected int
poll()
The polling method which is invoked periodically to poll this consumervoid
setSplitResult(boolean splitResult)
Object
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, getBackoffCounter, getBackoffErrorThreshold, getBackoffIdleThreshold, getBackoffMultiplier, getCounter, getDelay, getErrorCounter, getInitialDelay, getLastError, getLastErrorDetails, getPollStrategy, getRepeatCount, getRunLoggingLevel, getScheduledExecutorService, getScheduler, getSchedulerProperties, getSuccessCounter, getTimeUnit, initialHealthCheckState, 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, releaseExchange, setExceptionHandler, setHealthCheck, setRoute, setRouteId, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doFail, doLifecycleChange, doResume, 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.health.HealthCheckAware
getHealthCheck, setHealthCheck
-
-
-
-
Constructor Detail
-
AbstractApiConsumer
public AbstractApiConsumer(AbstractApiEndpoint<E,T> endpoint, org.apache.camel.Processor processor)
-
-
Method Detail
-
isGreedy
public boolean isGreedy()
- Overrides:
isGreedy
in classScheduledPollConsumer
-
poll
protected int poll() throws Exception
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
public void interceptPropertyNames(Set<String> propertyNames)
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
public void interceptProperties(Map<String,Object> properties)
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
protected Object doInvokeMethod(Map<String,Object> args)
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
public Object splitResult(Object result)
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
public void interceptResult(Object result, org.apache.camel.Exchange resultExchange)
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)
-
-