Class WebsocketEndpoint

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultEndpoint
org.apache.camel.component.websocket.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
  • Constructor Summary

    Constructors
    Constructor
    Description
    WebsocketEndpoint(WebsocketComponent component, String uri, String resourceUri)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
     
    org.apache.camel.Consumer
    createConsumer(org.apache.camel.Processor processor)
     
    org.apache.camel.Producer
     
    void
     
    void
     
     
     
     
     
    List<org.eclipse.jetty.server.Handler>
     
     
     
     
     
     
     
     
     
     
     
     
    org.apache.camel.support.jsse.SSLContextParameters
     
     
     
    boolean
     
    boolean
     
    boolean
     
    void
    setAllowedOrigins(String allowedOrigins)
    The CORS allowed origins.
    void
    setBufferSize(Integer bufferSize)
    Set the buffer size of the websocketServlet, which is also the max frame byte size (default 8192)
    void
    setCrossOriginFilterOn(boolean crossOriginFilterOn)
    Whether to enable CORS
    void
    setEnableJmx(boolean enableJmx)
    If this option is true, Jetty JMX support will be enabled for this endpoint.
    void
    setFilterPath(String filterPath)
    Context path for filtering CORS
    void
    setHandlers(List<org.eclipse.jetty.server.Handler> handlers)
     
    void
    The hostname.
    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.
    void
    setMaxIdleTime(Integer maxIdleTime)
    Set the time in ms that the websocket created by the websocketServlet may be idle before closing.
    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.
    void
    setMinVersion(Integer minVersion)
    Can be used to set the minimum protocol version accepted for the websocketServlet.
    void
    setPort(int port)
    The port number.
    void
    setResourceUri(String resourceUri)
    Name of the websocket channel to use
    void
    setSendTimeout(Integer sendTimeout)
    Timeout in millis when sending to a websocket channel.
    void
    setSendToAll(Boolean sendToAll)
    To send to all websocket subscribers.
    void
    setSessionSupport(boolean support)
    Whether to enable session support which enables HttpSession for each http request.
    void
    setSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)
    To configure security using SSLContextParameters
    void
    setStaticResources(String staticResources)
    Set a resource path for static resources (such as .html files etc).
    void
    setSubprotocol(String subprotocol)
    This is a comma-separated list of subprotocols that are supported by the application.

    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 class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    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
  • Constructor Details

  • Method Details

    • 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
    • connect

      public void connect(WebsocketConsumer consumer) throws Exception
      Throws:
      Exception
    • disconnect

      public void disconnect(WebsocketConsumer consumer) throws Exception
      Throws:
      Exception
    • connect

      public void connect(WebsocketProducer producer) throws Exception
      Throws:
      Exception
    • disconnect

      public void disconnect(WebsocketProducer producer) 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
    • getSubprotocol

      public String getSubprotocol()
    • 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: