Class WebsocketEndpoint

  • 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.10.0",
                 scheme="websocket",
                 title="Jetty Websocket",
                 syntax="websocket:host:port/resourceUri",
                 category=WEBSOCKET,
                 headersClass=WebsocketConstants.class)
    public class WebsocketEndpoint
    extends org.apache.camel.support.DefaultEndpoint
    Expose websocket endpoints using Jetty.
    • 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 Detail

      • getComponent

        public WebsocketComponent getComponent()
        Overrides:
        getComponent in class org.apache.camel.support.DefaultEndpoint
      • createConsumer

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

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

        public URI getUri()
      • getPort

        public Integer getPort()
      • getHost

        public String getHost()
      • setHost

        public void setHost​(String host)
        The hostname. The default value is 0.0.0.0. Setting this option on the component will use the component configured value as default.
      • setPort

        public void setPort​(int port)
        The port number. The default value is 9292. Setting this option on the component will use the component configured value as default.
      • getStaticResources

        public String getStaticResources()
      • setStaticResources

        public void setStaticResources​(String staticResources)
        Set a resource path for static resources (such as .html files etc).

        The resources can be loaded from classpath, if you prefix with classpath:, otherwise the resources is loaded from file system or from JAR files.

        For example to load from root classpath use classpath:., or classpath:WEB-INF/static

        If not configured (eg null) then no static resource is in use.

      • getSendToAll

        public Boolean getSendToAll()
      • setSendToAll

        public void setSendToAll​(Boolean sendToAll)
        To send to all websocket subscribers. Can be used to configure on endpoint level, instead of having to use the WebsocketConstants.SEND_TO_ALL header on the message.
      • getSendTimeout

        public Integer getSendTimeout()
      • setSendTimeout

        public void setSendTimeout​(Integer sendTimeout)
        Timeout in millis when sending to a websocket channel. The default timeout is 30000 (30 seconds).
      • getProtocol

        public String getProtocol()
      • getPath

        public String getPath()
      • setSessionSupport

        public void setSessionSupport​(boolean support)
        Whether to enable session support which enables HttpSession for each http request.
      • isSessionSupport

        public boolean isSessionSupport()
      • getBufferSize

        public Integer getBufferSize()
      • setBufferSize

        public void setBufferSize​(Integer bufferSize)
        Set the buffer size of the websocketServlet, which is also the max frame byte size (default 8192)
      • getMaxIdleTime

        public Integer getMaxIdleTime()
      • setMaxIdleTime

        public void setMaxIdleTime​(Integer maxIdleTime)
        Set the time in ms that the websocket created by the websocketServlet may be idle before closing. (default is 300000)
      • getMaxTextMessageSize

        public Integer getMaxTextMessageSize()
      • setMaxTextMessageSize

        public void setMaxTextMessageSize​(Integer maxTextMessageSize)
        Can be used to set the size in characters that the websocket created by the websocketServlet may be accept before closing.
      • getMaxBinaryMessageSize

        public Integer getMaxBinaryMessageSize()
      • setMaxBinaryMessageSize

        public void setMaxBinaryMessageSize​(Integer maxBinaryMessageSize)
        Can be used to set the size in bytes that the websocket created by the websocketServlet may be accept before closing. (Default is -1 - or unlimited)
      • getMinVersion

        public Integer getMinVersion()
      • setMinVersion

        public void setMinVersion​(Integer minVersion)
        Can be used to set the minimum protocol version accepted for the websocketServlet. (Default 13 - the RFC6455 version)
      • getHandlers

        public List<org.eclipse.jetty.server.Handler> getHandlers()
      • setHandlers

        public void setHandlers​(List<org.eclipse.jetty.server.Handler> handlers)
      • getSslContextParameters

        public org.apache.camel.support.jsse.SSLContextParameters getSslContextParameters()
      • setSslContextParameters

        public void setSslContextParameters​(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)
        To configure security using SSLContextParameters
      • isEnableJmx

        public boolean isEnableJmx()
      • setEnableJmx

        public void setEnableJmx​(boolean enableJmx)
        If this option is true, Jetty JMX support will be enabled for this endpoint. See Jetty JMX support for more details.
      • getAllowedOrigins

        public String getAllowedOrigins()
      • setAllowedOrigins

        public void setAllowedOrigins​(String allowedOrigins)
        The CORS allowed origins. Use * to allow all.
      • isCrossOriginFilterOn

        public boolean isCrossOriginFilterOn()
      • setCrossOriginFilterOn

        public void setCrossOriginFilterOn​(boolean crossOriginFilterOn)
        Whether to enable CORS
      • getFilterPath

        public String getFilterPath()
      • setFilterPath

        public void setFilterPath​(String filterPath)
        Context path for filtering CORS
      • getResourceUri

        public String getResourceUri()
      • setResourceUri

        public void setResourceUri​(String resourceUri)
        Name of the websocket channel to use
      • setSubprotocol

        public void setSubprotocol​(String subprotocol)

        This is a comma-separated list of subprotocols that are supported by the application. The list is in priority order. The first subprotocol on this list that is proposed by the client is the one that will be accepted. If no subprotocol on this list is proposed by the client, then the websocket connection is refused. The special value 'any' means that any subprotocol is acceptable. 'any' can be used on its own, or as a failsafe at the end of a list of more specific protocols. 'any' will also match the case where no subprotocol is proposed by the client.

        See Also:
        The official IANA list of registered websocket subprotocols