Class CometdEndpoint

  • 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

    @UriEndpoint(firstVersion="2.0.0",
                 scheme="cometd,cometds",
                 title="CometD",
                 syntax="cometd:host:port/channelName",
                 category=WEBSOCKET)
    public class CometdEndpoint
    extends org.apache.camel.support.DefaultEndpoint
    Offers publish/subscribe, peer-to-peer (via a server), and RPC style messaging using the CometD/Bayeux protocol. Using this component in combination with the dojo toolkit library it's possible to push Camel messages directly into the browser using an AJAX based mechanism.
    • 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void connect​(CometdProducerConsumer prodcons)  
      org.apache.camel.Consumer createConsumer​(org.apache.camel.Processor processor)  
      org.apache.camel.Producer createProducer()  
      void disconnect​(CometdProducerConsumer prodcons)  
      String getAllowedOrigins()  
      String getBaseResource()  
      CometdComponent getComponent()  
      String getFilterPath()  
      int getInterval()  
      int getLogLevel()  
      int getMaxInterval()  
      int getMultiFrameInterval()  
      String getPath()  
      int getPort()  
      String getProtocol()  
      int getTimeout()  
      URI getUri()  
      boolean isCrossOriginFilterOn()  
      boolean isDisconnectLocalSession()  
      boolean isJsonCommented()  
      boolean isSessionHeadersEnabled()  
      void setAllowedOrigins​(String allowedOrigins)
      The origins domain that support to cross, if the crosssOriginFilterOn is true
      void setBaseResource​(String baseResource)
      The root directory for the web resources or classpath.
      void setCrossOriginFilterOn​(boolean crossOriginFilterOn)
      If true, the server will support for cross-domain filtering
      void setDisconnectLocalSession​(boolean disconnectLocalSession)
      Whether to disconnect local sessions after publishing a message to its channel.
      void setFilterPath​(String filterPath)
      The filterPath will be used by the CrossOriginFilter, if the crosssOriginFilterOn is true
      void setInterval​(int interval)
      The client side poll timeout in milliseconds.
      void setJsonCommented​(boolean commented)
      If true, the server will accept JSON wrapped in a comment and will generate JSON wrapped in a comment.
      void setLogLevel​(int logLevel)
      Logging level.
      void setMaxInterval​(int maxInterval)
      The max client side poll timeout in milliseconds.
      void setMultiFrameInterval​(int multiFrameInterval)
      The client side poll timeout, if multiple connections are detected from the same browser.
      void setSessionHeadersEnabled​(boolean enable)
      Whether to include the server session headers in the Camel message when creating a Camel Message for incoming requests.
      void setTimeout​(int timeout)
      The server side poll timeout in milliseconds.
      • Methods inherited from class org.apache.camel.support.DefaultEndpoint

        configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, doStart, doStop, equals, getCamelContext, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString
      • Methods inherited from class org.apache.camel.support.service.BaseService

        build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, 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 interface org.apache.camel.Endpoint

        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
    • Method Detail

      • createProducer

        public org.apache.camel.Producer createProducer()
                                                 throws Exception
        Throws:
        Exception
      • createConsumer

        public org.apache.camel.Consumer createConsumer​(org.apache.camel.Processor processor)
                                                 throws Exception
        Throws:
        Exception
      • getComponent

        public CometdComponent getComponent()
        Overrides:
        getComponent in class org.apache.camel.support.DefaultEndpoint
      • getPath

        public String getPath()
      • getPort

        public int getPort()
      • getProtocol

        public String getProtocol()
      • getUri

        public URI getUri()
      • getBaseResource

        public String getBaseResource()
      • setBaseResource

        public void setBaseResource​(String baseResource)
        The root directory for the web resources or classpath. Use the protocol file: or classpath: depending if you want that the component loads the resource from file system or classpath. Classpath is required for OSGI deployment where the resources are packaged in the jar
      • getTimeout

        public int getTimeout()
      • setTimeout

        public void setTimeout​(int timeout)
        The server side poll timeout in milliseconds. This is how long the server will hold a reconnect request before responding.
      • getInterval

        public int getInterval()
      • setInterval

        public void setInterval​(int interval)
        The client side poll timeout in milliseconds. How long a client will wait between reconnects
      • getMaxInterval

        public int getMaxInterval()
      • setMaxInterval

        public void setMaxInterval​(int maxInterval)
        The max client side poll timeout in milliseconds. A client will be removed if a connection is not received in this time.
      • getMultiFrameInterval

        public int getMultiFrameInterval()
      • setMultiFrameInterval

        public void setMultiFrameInterval​(int multiFrameInterval)
        The client side poll timeout, if multiple connections are detected from the same browser.
      • isJsonCommented

        public boolean isJsonCommented()
      • setJsonCommented

        public void setJsonCommented​(boolean commented)
        If true, the server will accept JSON wrapped in a comment and will generate JSON wrapped in a comment. This is a defence against Ajax Hijacking.
      • setSessionHeadersEnabled

        public void setSessionHeadersEnabled​(boolean enable)
        Whether to include the server session headers in the Camel message when creating a Camel Message for incoming requests.
      • isSessionHeadersEnabled

        public boolean isSessionHeadersEnabled()
      • getLogLevel

        public int getLogLevel()
      • setLogLevel

        public void setLogLevel​(int logLevel)
        Logging level. 0=none, 1=info, 2=debug.
      • getAllowedOrigins

        public String getAllowedOrigins()
      • setAllowedOrigins

        public void setAllowedOrigins​(String allowedOrigins)
        The origins domain that support to cross, if the crosssOriginFilterOn is true
      • isCrossOriginFilterOn

        public boolean isCrossOriginFilterOn()
      • setCrossOriginFilterOn

        public void setCrossOriginFilterOn​(boolean crossOriginFilterOn)
        If true, the server will support for cross-domain filtering
      • getFilterPath

        public String getFilterPath()
      • setFilterPath

        public void setFilterPath​(String filterPath)
        The filterPath will be used by the CrossOriginFilter, if the crosssOriginFilterOn is true
      • isDisconnectLocalSession

        public boolean isDisconnectLocalSession()
      • setDisconnectLocalSession

        public void setDisconnectLocalSession​(boolean disconnectLocalSession)
        Whether to disconnect local sessions after publishing a message to its channel. Disconnecting local session is needed as they are not swept by default by CometD, and therefore you can run out of memory.