public abstract class DefaultEndpoint extends ServiceSupport implements Endpoint, HasId, CamelContextAware
isSynchronous()
to determine
if asynchronous processing is allowed. The synchronous option on the
endpoint allows Camel end users to dictate whether they want the asynchronous
model or not. The option is default false which means asynchronous
processing is allowed.shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Modifier | Constructor and Description |
---|---|
protected |
DefaultEndpoint()
Constructs a partially-initialized DefaultEndpoint instance.
|
protected |
DefaultEndpoint(String endpointUri)
Deprecated.
|
protected |
DefaultEndpoint(String endpointUri,
CamelContext camelContext)
Deprecated.
|
protected |
DefaultEndpoint(String endpointUri,
Component component)
Constructs a fully-initialized DefaultEndpoint instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
configureConsumer(Consumer consumer) |
protected void |
configurePollingConsumer(PollingConsumer consumer) |
void |
configureProperties(Map<String,Object> options)
Configure properties on this endpoint.
|
protected EndpointConfiguration |
createEndpointConfiguration(String uri)
A factory method to lazily create the endpoint configuration if none is specified
|
protected String |
createEndpointUri()
A factory method to lazily create the endpointUri if none is specified
|
Exchange |
createExchange()
Create a new exchange for communicating with this endpoint
|
Exchange |
createExchange(Exchange exchange)
Creates a new exchange for communicating with this endpoint using the
given exchange to pre-populate the values of the headers and messages
|
Exchange |
createExchange(ExchangePattern pattern)
Create a new exchange for communicating with this endpoint
with the specified
ExchangePattern such as whether its going
to be an ExchangePattern.InOnly or ExchangePattern.InOut exchange |
PollingConsumer |
createPollingConsumer()
Creates a new Polling
Consumer so that the caller can poll message exchanges from the
consumer using
PollingConsumer.receive() ,
PollingConsumer.receiveNoWait() or
PollingConsumer.receive(long) whenever it is ready to do so
rather than using the Event
Based Consumer returned by Endpoint.createConsumer(Processor) |
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
boolean |
equals(Object object) |
CamelContext |
getCamelContext()
Returns the context which created the endpoint
|
Component |
getComponent()
Returns the component that created this endpoint.
|
Map<String,Object> |
getConsumerProperties() |
EndpointConfiguration |
getEndpointConfiguration()
Returns the object representation of the endpoint configuration
|
String |
getEndpointKey()
Returns a string key of this endpoint.
|
String |
getEndpointUri()
Returns the string representation of the endpoint URI
|
ExceptionHandler |
getExceptionHandler() |
ExchangePattern |
getExchangePattern()
Returns the default exchange pattern to use when creating an exchange.
|
String |
getId()
Returns a unique String ID which can be used for aliasing without having
to use the whole URI which is not unique
|
long |
getPollingConsumerBlockTimeout()
Sets the timeout in millis to use when adding to the internal queue off when
EventDrivenPollingConsumer
is being used. |
int |
getPollingConsumerQueueSize()
Gets the
PollingConsumer queue size, when EventDrivenPollingConsumer
is being used. |
int |
hashCode() |
boolean |
isBridgeErrorHandler() |
boolean |
isLenientProperties()
Should all properties be known or does the endpoint allow unknown options?
lenient = false means that the endpoint should validate that all
given options is known and configured properly.
|
boolean |
isPollingConsumerBlockWhenFull()
Whether to block when adding to the internal queue off when
EventDrivenPollingConsumer
is being used. |
boolean |
isSynchronous()
Returns whether synchronous processing should be strictly used.
|
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(CamelContext camelContext)
Sets the camel context.
|
void |
setConsumerProperties(Map<String,Object> consumerProperties) |
void |
setEndpointConfiguration(EndpointConfiguration endpointConfiguration)
Sets a custom
EndpointConfiguration |
protected void |
setEndpointUri(String endpointUri)
Sets the URI that created this endpoint.
|
void |
setEndpointUriIfNotSpecified(String value)
Sets the endpointUri if it has not been specified yet via some kind of
dependency injection mechanism.
|
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
To let the consumer use a custom ExceptionHandler.
|
void |
setExchangePattern(ExchangePattern exchangePattern)
Sets the default exchange pattern when creating an exchange.
|
void |
setPollingConsumerBlockTimeout(long pollingConsumerBlockTimeout)
Sets the timeout in millis to use when adding to the internal queue off when
EventDrivenPollingConsumer
is being used. |
void |
setPollingConsumerBlockWhenFull(boolean pollingConsumerBlockWhenFull)
Set whether to block when adding to the internal queue off when
EventDrivenPollingConsumer
is being used. |
void |
setPollingConsumerQueueSize(int pollingConsumerQueueSize)
Sets the
PollingConsumer queue size, when EventDrivenPollingConsumer
is being used. |
protected void |
setProperties(Object bean,
Map<String,Object> parameters)
Sets the bean properties on the given bean.
|
void |
setSynchronous(boolean synchronous)
Sets whether synchronous processing should be strictly used, or Camel is
allowed to use asynchronous processing (if supported).
|
String |
toString() |
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
createConsumer, createProducer
isSingleton
protected DefaultEndpoint(String endpointUri, Component component)
endpointUri
- the full URI used to create this endpointcomponent
- the component that created this endpoint@Deprecated protected DefaultEndpoint(String endpointUri, CamelContext camelContext)
Component
.
Note: It is preferred to create endpoints using the associated
component.endpointUri
- the full URI used to create this endpointcamelContext
- the Camel Context in which this endpoint is operating@Deprecated protected DefaultEndpoint(String endpointUri)
endpointUri
- the full URI used to create this endpointprotected DefaultEndpoint()
createEndpointUri()
if one uses this constructor.
Note: It is preferred to create endpoints using the associated
component.public String getId()
public String getEndpointUri()
Endpoint
getEndpointUri
in interface Endpoint
public EndpointConfiguration getEndpointConfiguration()
Endpoint
getEndpointConfiguration
in interface Endpoint
public void setEndpointConfiguration(EndpointConfiguration endpointConfiguration)
EndpointConfiguration
endpointConfiguration
- a custom endpoint configuration to be used.public String getEndpointKey()
Endpoint
LifecycleStrategy
when registering endpoint.
This allows to register different instances of endpoints with the same key.
For JMX mbeans this allows us to use the same JMX Mbean for all endpoints that are logical
the same but have different parameters. For instance the http endpoint.getEndpointKey
in interface Endpoint
public CamelContext getCamelContext()
Endpoint
getCamelContext
in interface CamelContextAware
getCamelContext
in interface Endpoint
public Component getComponent()
public void setCamelContext(CamelContext camelContext)
Endpoint
setCamelContext
in interface CamelContextAware
setCamelContext
in interface Endpoint
camelContext
- the camel contextpublic PollingConsumer createPollingConsumer() throws Exception
Endpoint
PollingConsumer.receive()
,
PollingConsumer.receiveNoWait()
or
PollingConsumer.receive(long)
whenever it is ready to do so
rather than using the Event
Based Consumer returned by Endpoint.createConsumer(Processor)
createPollingConsumer
in interface Endpoint
Exception
- if the pull consumer could not be createdpublic Exchange createExchange(Exchange exchange)
Endpoint
createExchange
in interface Endpoint
exchange
- given exchange to use for pre-populatepublic Exchange createExchange()
Endpoint
createExchange
in interface Endpoint
public Exchange createExchange(ExchangePattern pattern)
Endpoint
ExchangePattern
such as whether its going
to be an ExchangePattern.InOnly
or ExchangePattern.InOut
exchangecreateExchange
in interface Endpoint
pattern
- the message exchange pattern for the exchangepublic ExchangePattern getExchangePattern()
public void setExchangePattern(ExchangePattern exchangePattern)
public boolean isSynchronous()
public void setSynchronous(boolean synchronous)
synchronous
- true to enforce synchronous processingpublic boolean isBridgeErrorHandler()
public void setBridgeErrorHandler(boolean bridgeErrorHandler)
public ExceptionHandler getExceptionHandler()
public void setExceptionHandler(ExceptionHandler exceptionHandler)
public int getPollingConsumerQueueSize()
PollingConsumer
queue size, when EventDrivenPollingConsumer
is being used. Notice some Camel components may have their own implementation of PollingConsumer
and
therefore not using the default EventDrivenPollingConsumer
implementation.
The default value is 1000public void setPollingConsumerQueueSize(int pollingConsumerQueueSize)
PollingConsumer
queue size, when EventDrivenPollingConsumer
is being used. Notice some Camel components may have their own implementation of PollingConsumer
and
therefore not using the default EventDrivenPollingConsumer
implementation.
The default value is 1000public boolean isPollingConsumerBlockWhenFull()
EventDrivenPollingConsumer
is being used. Notice some Camel components may have their own implementation of PollingConsumer
and
therefore not using the default EventDrivenPollingConsumer
implementation.
Setting this option to false, will result in an IllegalStateException
being thrown
when trying to add to the queue, and its full.
The default value is true which will block the producer queue until the queue has space.public void setPollingConsumerBlockWhenFull(boolean pollingConsumerBlockWhenFull)
EventDrivenPollingConsumer
is being used. Notice some Camel components may have their own implementation of PollingConsumer
and
therefore not using the default EventDrivenPollingConsumer
implementation.
Setting this option to false, will result in an IllegalStateException
being thrown
when trying to add to the queue, and its full.
The default value is true which will block the producer queue until the queue has space.public long getPollingConsumerBlockTimeout()
EventDrivenPollingConsumer
is being used.setPollingConsumerBlockWhenFull(boolean)
public void setPollingConsumerBlockTimeout(long pollingConsumerBlockTimeout)
EventDrivenPollingConsumer
is being used.setPollingConsumerBlockWhenFull(boolean)
public void configureProperties(Map<String,Object> options)
Endpoint
configureProperties
in interface Endpoint
options
- the options (properties)protected void setProperties(Object bean, Map<String,Object> parameters) throws Exception
DefaultComponent.setProperties(Object, java.util.Map)
bean
- the beanparameters
- properties to setException
protected String createEndpointUri()
protected EndpointConfiguration createEndpointConfiguration(String uri)
public void setEndpointUriIfNotSpecified(String value)
protected void setEndpointUri(String endpointUri)
public boolean isLenientProperties()
Endpoint
isLenientProperties
in interface Endpoint
public Map<String,Object> getConsumerProperties()
public void setConsumerProperties(Map<String,Object> consumerProperties)
protected void configureConsumer(Consumer consumer) throws Exception
Exception
protected void configurePollingConsumer(PollingConsumer consumer) throws Exception
Exception
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
Apache Camel