Package org.apache.camel.support
Class DefaultEndpoint
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultEndpoint
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.ComponentAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasCamelContext
,org.apache.camel.spi.HasId
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
- Direct Known Subclasses:
ScheduledPollEndpoint
public abstract class DefaultEndpoint
extends org.apache.camel.support.service.ServiceSupport
implements org.apache.camel.Endpoint, org.apache.camel.spi.HasId, org.apache.camel.CamelContextAware
Default
Endpoint
.-
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
ConstructorsModifierConstructorDescriptionprotected
Constructs a partially-initialized DefaultEndpoint instance.protected
DefaultEndpoint
(String endpointUri, org.apache.camel.Component component) Constructs a fully-initialized DefaultEndpoint instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureConsumer
(org.apache.camel.Consumer consumer) void
configureExchange
(org.apache.camel.Exchange exchange) protected void
configurePollingConsumer
(org.apache.camel.PollingConsumer consumer) void
configureProperties
(Map<String, Object> options) org.apache.camel.AsyncProducer
protected String
A factory method to lazily create the endpointUri if none is specifiedorg.apache.camel.Exchange
org.apache.camel.Exchange
createExchange
(org.apache.camel.ExchangePattern pattern) org.apache.camel.PollingConsumer
protected void
doInit()
boolean
org.apache.camel.CamelContext
org.apache.camel.Component
Returns the component that created this endpoint, or null if none set.org.apache.camel.spi.ExceptionHandler
org.apache.camel.ExchangePattern
getId()
Returns a unique String ID which can be used for aliasing without having to use the whole URI which is not uniquelong
int
int
hashCode()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
An endpoint should favour to be singleton by default, only in some rare special cases can an endpoint be non-singleton.void
setAutowiredEnabled
(boolean autowiredEnabled) Whether autowiring is enabled.void
setBridgeErrorHandler
(boolean bridgeErrorHandler) Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler.void
setCamelContext
(org.apache.camel.CamelContext camelContext) void
setComponent
(org.apache.camel.Component component) protected void
setEndpointUri
(String endpointUri) Sets the URI that created this endpoint.void
Sets the endpointUri if it has not been specified yet via some kind of dependency injection mechanism.void
setExceptionHandler
(org.apache.camel.spi.ExceptionHandler exceptionHandler) To let the consumer use a custom ExceptionHandler.void
setExchangePattern
(org.apache.camel.ExchangePattern exchangePattern) Sets the default exchange pattern when creating an exchange.void
setLazyStartProducer
(boolean lazyStartProducer) Whether the producer should be started lazy (on the first message).void
setPollingConsumerBlockTimeout
(long pollingConsumerBlockTimeout) Sets the timeout in millis to use when adding to the internal queue off whenEventDrivenPollingConsumer
is being used.void
setPollingConsumerBlockWhenFull
(boolean pollingConsumerBlockWhenFull) Set whether to block when adding to the internal queue off whenEventDrivenPollingConsumer
is being used.void
setPollingConsumerCopy
(boolean pollingConsumerCopy) Sets whether to copy the exchange when adding to the internal queue off whenEventDrivenPollingConsumer
is being used.void
setPollingConsumerQueueSize
(int pollingConsumerQueueSize) Sets thePollingConsumer
queue size, whenEventDrivenPollingConsumer
is being used.void
setProperties
(Object bean, Map<String, Object> parameters) Sets the bean properties on the given bean.toString()
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doStart, doStop, 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, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.camel.ComponentAware
getComponent
Methods inherited from interface org.apache.camel.Endpoint
createConsumer, createProducer, getEndpointBaseUri, isSingletonProducer
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
-
DefaultEndpoint
Constructs a fully-initialized DefaultEndpoint instance. This is the preferred method of constructing an object from Java code (as opposed to Spring beans, etc.).- Parameters:
endpointUri
- the full URI used to create this endpointcomponent
- the component that created this endpoint
-
DefaultEndpoint
protected DefaultEndpoint()Constructs a partially-initialized DefaultEndpoint instance. Useful when creating endpoints manually (e.g., as beans in Spring). Please note that the endpoint URI must be set through properties (or overridingcreateEndpointUri()
if one uses this constructor. Note: It is preferred to create endpoints using the associated component.
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
toString
-
getId
Returns a unique String ID which can be used for aliasing without having to use the whole URI which is not unique- Specified by:
getId
in interfaceorg.apache.camel.spi.HasId
-
getEndpointUri
- Specified by:
getEndpointUri
in interfaceorg.apache.camel.Endpoint
-
getEndpointKey
- Specified by:
getEndpointKey
in interfaceorg.apache.camel.Endpoint
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
getCamelContext
in interfaceorg.apache.camel.Endpoint
- Specified by:
getCamelContext
in interfaceorg.apache.camel.spi.HasCamelContext
-
createAsyncProducer
- Specified by:
createAsyncProducer
in interfaceorg.apache.camel.Endpoint
- Throws:
Exception
-
getComponent
public org.apache.camel.Component getComponent()Returns the component that created this endpoint, or null if none set.- Specified by:
getComponent
in interfaceorg.apache.camel.ComponentAware
-
setComponent
public void setComponent(org.apache.camel.Component component) - Specified by:
setComponent
in interfaceorg.apache.camel.ComponentAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContext
in interfaceorg.apache.camel.CamelContextAware
- Specified by:
setCamelContext
in interfaceorg.apache.camel.Endpoint
-
createPollingConsumer
- Specified by:
createPollingConsumer
in interfaceorg.apache.camel.Endpoint
- Throws:
Exception
-
createExchange
public org.apache.camel.Exchange createExchange()- Specified by:
createExchange
in interfaceorg.apache.camel.Endpoint
-
createExchange
public org.apache.camel.Exchange createExchange(org.apache.camel.ExchangePattern pattern) - Specified by:
createExchange
in interfaceorg.apache.camel.Endpoint
-
configureExchange
public void configureExchange(org.apache.camel.Exchange exchange) - Specified by:
configureExchange
in interfaceorg.apache.camel.Endpoint
-
getExchangePattern
public org.apache.camel.ExchangePattern getExchangePattern()- Specified by:
getExchangePattern
in interfaceorg.apache.camel.Endpoint
-
setExchangePattern
public void setExchangePattern(org.apache.camel.ExchangePattern exchangePattern) Sets the default exchange pattern when creating an exchange. -
isAutowiredEnabled
public boolean isAutowiredEnabled() -
setAutowiredEnabled
public void setAutowiredEnabled(boolean autowiredEnabled) Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. Important: If a component has the same option defined on both component and endpoint level, then disabling autowiring on endpoint level would not affect that the component will still be autowired, and therefore the endpoint will be configured with option from the component level. In other words turning off autowiring would then require to turn it off on the component level. -
isLazyStartProducer
public boolean isLazyStartProducer() -
setLazyStartProducer
public void setLazyStartProducer(boolean lazyStartProducer) Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. -
isBridgeErrorHandler
public boolean isBridgeErrorHandler() -
setBridgeErrorHandler
public void setBridgeErrorHandler(boolean bridgeErrorHandler) Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN/ERROR level and ignored. -
getExceptionHandler
public org.apache.camel.spi.ExceptionHandler getExceptionHandler() -
setExceptionHandler
public void setExceptionHandler(org.apache.camel.spi.ExceptionHandler exceptionHandler) To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions, that will be logged at WARN/ERROR level and ignored. -
getPollingConsumerQueueSize
public int getPollingConsumerQueueSize() -
setPollingConsumerQueueSize
public void setPollingConsumerQueueSize(int pollingConsumerQueueSize) Sets thePollingConsumer
queue size, whenEventDrivenPollingConsumer
is being used. Notice some Camel components may have their own implementation ofPollingConsumer
and therefore not using the defaultEventDrivenPollingConsumer
implementation. The default value is 1000 -
isPollingConsumerBlockWhenFull
public boolean isPollingConsumerBlockWhenFull() -
setPollingConsumerBlockWhenFull
public void setPollingConsumerBlockWhenFull(boolean pollingConsumerBlockWhenFull) Set whether to block when adding to the internal queue off whenEventDrivenPollingConsumer
is being used. Notice some Camel components may have their own implementation ofPollingConsumer
and therefore not using the defaultEventDrivenPollingConsumer
implementation. Setting this option to false, will result in anIllegalStateException
being thrown when trying to add to the queue, and it is full. The default value is true which will block the producer queue until the queue has space. -
getPollingConsumerBlockTimeout
public long getPollingConsumerBlockTimeout() -
setPollingConsumerBlockTimeout
public void setPollingConsumerBlockTimeout(long pollingConsumerBlockTimeout) Sets the timeout in millis to use when adding to the internal queue off whenEventDrivenPollingConsumer
is being used.- See Also:
-
isPollingConsumerCopy
public boolean isPollingConsumerCopy() -
setPollingConsumerCopy
public void setPollingConsumerCopy(boolean pollingConsumerCopy) Sets whether to copy the exchange when adding to the internal queue off whenEventDrivenPollingConsumer
is being used. Important: When copy is enabled then the unit of work is handed over from the current exchange to the copied exchange instance. And therefore its the responsible of thePollingConsumer
to done the unit of work on the received exchanges. When the polled exchange is no longer needed then MUST callUnitOfWork.done(Exchange)
. Default is false to not copy. -
configureProperties
- Specified by:
configureProperties
in interfaceorg.apache.camel.Endpoint
-
setProperties
Sets the bean properties on the given bean. This is the same logical implementation asDefaultComponent.setProperties(Object, java.util.Map)
- Parameters:
bean
- the beanparameters
- properties to set
-
createEndpointUri
A factory method to lazily create the endpointUri if none is specified -
setEndpointUriIfNotSpecified
Sets the endpointUri if it has not been specified yet via some kind of dependency injection mechanism. This allows dependency injection frameworks such as Spring to set the default endpoint URI in cases where it has not been explicitly configured using the name/context in which an Endpoint is created. -
setEndpointUri
Sets the URI that created this endpoint. -
isSingleton
public boolean isSingleton()An endpoint should favour to be singleton by default, only in some rare special cases can an endpoint be non-singleton. This implementation is singleton and this method returns true.- Specified by:
isSingleton
in interfaceorg.apache.camel.IsSingleton
-
isLenientProperties
public boolean isLenientProperties()- Specified by:
isLenientProperties
in interfaceorg.apache.camel.Endpoint
-
configureConsumer
- Throws:
Exception
-
configurePollingConsumer
- Throws:
Exception
-
doInit
- Overrides:
doInit
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-