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
ConstructorsConstructorDescriptionWebsocketEndpoint
(WebsocketComponent component, String uri, String resourceUri) -
Method Summary
Modifier and TypeMethodDescriptionvoid
connect
(WebsocketConsumer consumer) void
connect
(WebsocketProducer producer) org.apache.camel.Consumer
createConsumer
(org.apache.camel.Processor processor) org.apache.camel.Producer
void
disconnect
(WebsocketConsumer consumer) void
disconnect
(WebsocketProducer producer) List<org.eclipse.jetty.server.Handler>
getHost()
getPath()
getPort()
org.apache.camel.support.jsse.SSLContextParameters
SeegetSubprotocol()
getUri()
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 CORSvoid
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 CORSvoid
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 usevoid
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 SSLContextParametersvoid
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
-
WebsocketEndpoint
-
-
Method Details
-
getComponent
- Overrides:
getComponent
in classorg.apache.camel.support.DefaultEndpoint
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception - Throws:
Exception
-
createProducer
- Throws:
Exception
-
connect
- Throws:
Exception
-
disconnect
- Throws:
Exception
-
connect
- Throws:
Exception
-
disconnect
- Throws:
Exception
-
getUri
-
getPort
-
getHost
-
setHost
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
-
setStaticResources
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
-
setSendToAll
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
-
setSendTimeout
Timeout in millis when sending to a websocket channel. The default timeout is 30000 (30 seconds). -
getProtocol
-
getPath
-
setSessionSupport
public void setSessionSupport(boolean support) Whether to enable session support which enables HttpSession for each http request. -
isSessionSupport
public boolean isSessionSupport() -
getBufferSize
-
setBufferSize
Set the buffer size of the websocketServlet, which is also the max frame byte size (default 8192) -
getMaxIdleTime
-
setMaxIdleTime
Set the time in ms that the websocket created by the websocketServlet may be idle before closing. (default is 300000) -
getMaxTextMessageSize
-
setMaxTextMessageSize
Can be used to set the size in characters that the websocket created by the websocketServlet may be accept before closing. -
getMaxBinaryMessageSize
-
setMaxBinaryMessageSize
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
-
setMinVersion
Can be used to set the minimum protocol version accepted for the websocketServlet. (Default 13 - the RFC6455 version) -
getHandlers
-
setHandlers
-
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
-
setAllowedOrigins
The CORS allowed origins. Use * to allow all. -
isCrossOriginFilterOn
public boolean isCrossOriginFilterOn() -
setCrossOriginFilterOn
public void setCrossOriginFilterOn(boolean crossOriginFilterOn) Whether to enable CORS -
getFilterPath
-
setFilterPath
Context path for filtering CORS -
getResourceUri
-
setResourceUri
Name of the websocket channel to use -
getSubprotocol
SeegetSubprotocol()
-
setSubprotocol
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.
-