Class DefaultEndpoint

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.Service, org.apache.camel.ShutdownableService, 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
    A default endpoint useful for implementation inheritance.

    Components which leverages asynchronous processing model should check the 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.

    • Field Summary

      • Fields inherited from class org.apache.camel.support.service.BaseService

        BUILDED, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTINGDOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected DefaultEndpoint()
      Constructs a partially-initialized DefaultEndpoint instance.
      protected DefaultEndpoint​(String endpointUri, org.apache.camel.Component component)
      Constructs a fully-initialized DefaultEndpoint instance.
    • Constructor Detail

      • DefaultEndpoint

        protected DefaultEndpoint​(String endpointUri,
                                  org.apache.camel.Component component)
        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 endpoint
        component - 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 overriding createEndpointUri() if one uses this constructor.

        Note: It is preferred to create endpoints using the associated component.

    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getId

        public String 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 interface org.apache.camel.spi.HasId
      • getEndpointUri

        public String getEndpointUri()
        Specified by:
        getEndpointUri in interface org.apache.camel.Endpoint
      • getEndpointKey

        public String getEndpointKey()
        Specified by:
        getEndpointKey in interface org.apache.camel.Endpoint
      • getCamelContext

        public org.apache.camel.CamelContext getCamelContext()
        Specified by:
        getCamelContext in interface org.apache.camel.CamelContextAware
        Specified by:
        getCamelContext in interface org.apache.camel.Endpoint
      • createAsyncProducer

        public org.apache.camel.AsyncProducer createAsyncProducer()
                                                           throws Exception
        Specified by:
        createAsyncProducer in interface org.apache.camel.Endpoint
        Throws:
        Exception
      • getComponent

        public org.apache.camel.Component getComponent()
        Returns the component that created this endpoint, or null if none set.
      • setComponent

        public void setComponent​(org.apache.camel.Component component)
      • setCamelContext

        public void setCamelContext​(org.apache.camel.CamelContext camelContext)
        Specified by:
        setCamelContext in interface org.apache.camel.CamelContextAware
        Specified by:
        setCamelContext in interface org.apache.camel.Endpoint
      • createPollingConsumer

        public org.apache.camel.PollingConsumer createPollingConsumer()
                                                               throws Exception
        Specified by:
        createPollingConsumer in interface org.apache.camel.Endpoint
        Throws:
        Exception
      • createExchange

        public org.apache.camel.Exchange createExchange()
        Specified by:
        createExchange in interface org.apache.camel.Endpoint
      • createExchange

        public org.apache.camel.Exchange createExchange​(org.apache.camel.ExchangePattern pattern)
        Specified by:
        createExchange in interface org.apache.camel.Endpoint
      • getExchangePattern

        public org.apache.camel.ExchangePattern getExchangePattern()
        Returns the default exchange pattern to use when creating an exchange.
      • setExchangePattern

        public void setExchangePattern​(org.apache.camel.ExchangePattern exchangePattern)
        Sets the default exchange pattern when creating an exchange.
      • isSynchronous

        public boolean isSynchronous()
        Returns whether synchronous processing should be strictly used.
      • setSynchronous

        public void setSynchronous​(boolean synchronous)
        Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported).
      • isBasicPropertyBinding

        public boolean isBasicPropertyBinding()
        Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities.
      • setBasicPropertyBinding

        public void setBasicPropertyBinding​(boolean basicPropertyBinding)
        Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities.
      • 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()
        Gets the 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 1000

      • setPollingConsumerQueueSize

        public void setPollingConsumerQueueSize​(int pollingConsumerQueueSize)
        Sets the 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 1000

      • isPollingConsumerBlockWhenFull

        public boolean isPollingConsumerBlockWhenFull()
        Whether to block when adding to the internal queue off when 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.

      • setPollingConsumerBlockWhenFull

        public void setPollingConsumerBlockWhenFull​(boolean pollingConsumerBlockWhenFull)
        Set whether to block when adding to the internal queue off when 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.

      • configureProperties

        public void configureProperties​(Map<String,​Object> options)
        Specified by:
        configureProperties in interface org.apache.camel.Endpoint
      • createEndpointUri

        protected String createEndpointUri()
        A factory method to lazily create the endpointUri if none is specified
      • setEndpointUriIfNotSpecified

        public void setEndpointUriIfNotSpecified​(String value)
        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

        protected void setEndpointUri​(String endpointUri)
        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 interface org.apache.camel.IsSingleton
      • isLenientProperties

        public boolean isLenientProperties()
        Specified by:
        isLenientProperties in interface org.apache.camel.Endpoint
      • configureConsumer

        protected void configureConsumer​(org.apache.camel.Consumer consumer)
                                  throws Exception
        Throws:
        Exception
      • configurePollingConsumer

        protected void configurePollingConsumer​(org.apache.camel.PollingConsumer consumer)
                                         throws Exception
        Throws:
        Exception
      • doInit

        protected void doInit()
                       throws Exception
        Overrides:
        doInit in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doStart

        protected void doStart()
                        throws Exception
        Overrides:
        doStart in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.service.BaseService
        Throws:
        Exception