Package org.apache.qpid.protonj2.client
Class TransportOptions
java.lang.Object
org.apache.qpid.protonj2.client.TransportOptions
- All Implemented Interfaces:
Cloneable
Encapsulates all the Transport options in one configuration object.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
static final int
static final int
static final int
static final int
static final int
static final int
static final boolean
static final boolean
static final int
static final boolean
static final int
static final boolean
static final boolean
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddWebSocketHeader
(String key, String value) Additional headers to be passed along to the remote when performing a WebSocket based connect.boolean
allowNativeIO
(boolean allowNativeIO) Determines if the a native IO implementation is preferred to the JDK based IO.clone()
int
connectTimeout
(int connectTimeout) A transport layer connection timeout value that controls how long a connection attempt can block before giving up and throwing a connection error.copyInto
(TransportOptions other) Copy all configuration into the givenTransportOptions
from this instance.int
defaultTcpPort
(int defaultTcpPort) The default unsecured connection port to use when none has been specified by the user.localAddress
(String localAddress) The local address to bind to when attempting a remote connection.int
localPort
(int localPort) Configures the local port value to bind to when connecting to the remote, if that port is already in use this can lead to a connection error.String[]
void
nativeIOPreference
(String... nativeIOPreference) int
receiveBufferSize
(int receiveBufferSize) Sets the receive buffer size in bytes, the value must be greater than zero or anIllegalArgumentException
will be thrown.int
sendBufferSize
(int sendBufferSize) Sets the send buffer size in bytes, the value must be greater than zero or anIllegalArgumentException
will be thrown.int
soLinger()
soLinger
(int soLinger) Configures the soLinger value that should be configured on the connection socket.int
soTimeout
(int soTimeout) Sets the value to use when configuring the socket level soTimeout option.boolean
tcpKeepAlive
(boolean keepAlive) Configures the TCP socket keep-alive value that should be used for a connection.boolean
tcpNoDelay
(boolean tcpNoDelay) Configure the underlying connection to use the tcpNoDelay option.boolean
traceBytes
(boolean traceBytes) Determines if the transport should add a logger for bytes in / outint
trafficClass
(int trafficClass) Sets the traffic class value used by the TCP connection, valid range is between 0 and 255.boolean
useWebSockets
(boolean webSockets) Set to true to configure the transport layer as a WebSocket based connection.boolean
webSocketCompression
(boolean enabled) Set to true to configure the transport layer as a WebSocket based connection that support compression of the WebSocket packets.int
webSocketMaxFrameSize
(int maxFrameSize) Configures the maximum size of each WebSocket frame, payloads larger than the max frame size are split into multiple frames during transmission.webSocketPath
(String webSocketPath) The optional path element to provide when connecting via a WebSocket.
-
Field Details
-
DEFAULT_SEND_BUFFER_SIZE
public static final int DEFAULT_SEND_BUFFER_SIZE- See Also:
-
DEFAULT_RECEIVE_BUFFER_SIZE
public static final int DEFAULT_RECEIVE_BUFFER_SIZE- See Also:
-
DEFAULT_TRAFFIC_CLASS
public static final int DEFAULT_TRAFFIC_CLASS- See Also:
-
DEFAULT_TCP_NO_DELAY
public static final boolean DEFAULT_TCP_NO_DELAY- See Also:
-
DEFAULT_TCP_KEEP_ALIVE
public static final boolean DEFAULT_TCP_KEEP_ALIVE- See Also:
-
DEFAULT_SO_LINGER
public static final int DEFAULT_SO_LINGER- See Also:
-
DEFAULT_SO_TIMEOUT
public static final int DEFAULT_SO_TIMEOUT- See Also:
-
DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_CONNECT_TIMEOUT- See Also:
-
DEFAULT_TCP_PORT
public static final int DEFAULT_TCP_PORT- See Also:
-
DEFAULT_ALLOW_NATIVE_IO
public static final boolean DEFAULT_ALLOW_NATIVE_IO- See Also:
-
DEFAULT_TRACE_BYTES
public static final boolean DEFAULT_TRACE_BYTES- See Also:
-
DEFAULT_LOCAL_PORT
public static final int DEFAULT_LOCAL_PORT- See Also:
-
DEFAULT_USE_WEBSOCKETS
public static final boolean DEFAULT_USE_WEBSOCKETS- See Also:
-
DEFAULT_WEBSOCKET_COMPRESSION
public static final boolean DEFAULT_WEBSOCKET_COMPRESSION- See Also:
-
DEFAULT_WEBSOCKET_MAX_FRAME_SIZE
public static final int DEFAULT_WEBSOCKET_MAX_FRAME_SIZE- See Also:
-
DEFAULT_NATIVEIO_PREFERENCES
-
-
Constructor Details
-
TransportOptions
public TransportOptions()
-
-
Method Details
-
clone
-
sendBufferSize
public int sendBufferSize()- Returns:
- the currently set send buffer size in bytes.
-
sendBufferSize
Sets the send buffer size in bytes, the value must be greater than zero or anIllegalArgumentException
will be thrown.- Parameters:
sendBufferSize
- the new send buffer size for the TCP Transport.- Returns:
- this options instance.
- Throws:
IllegalArgumentException
- if the value given is not in the valid range.
-
receiveBufferSize
public int receiveBufferSize()- Returns:
- the currently configured receive buffer size in bytes.
-
receiveBufferSize
Sets the receive buffer size in bytes, the value must be greater than zero or anIllegalArgumentException
will be thrown.- Parameters:
receiveBufferSize
- the new receive buffer size for the TCP Transport.- Returns:
- this options instance.
- Throws:
IllegalArgumentException
- if the value given is not in the valid range.
-
trafficClass
public int trafficClass()- Returns:
- the currently configured traffic class value.
-
trafficClass
Sets the traffic class value used by the TCP connection, valid range is between 0 and 255.- Parameters:
trafficClass
- the new traffic class value.- Returns:
- this options instance.
- Throws:
IllegalArgumentException
- if the value given is not in the valid range.
-
soTimeout
public int soTimeout()- Returns:
- the configured value for the socket level soTimeout option.
-
soTimeout
Sets the value to use when configuring the socket level soTimeout option.- Parameters:
soTimeout
- the soTimeout value to configure on the newly create socket.- Returns:
- this
TransportOptions
instance.
-
tcpNoDelay
public boolean tcpNoDelay()- Returns:
- the configured value for the socket level tcpNoDelay option.
-
tcpNoDelay
Configure the underlying connection to use the tcpNoDelay option.- Parameters:
tcpNoDelay
- controls if the underlying connection configures tcpNoDelay.- Returns:
- this
TransportOptions
instance.
-
soLinger
public int soLinger()- Returns:
- the configured value for the socket level soLinger option.
-
soLinger
Configures the soLinger value that should be configured on the connection socket.- Parameters:
soLinger
- The soLinger value to use for the underlying socket.- Returns:
- this
TransportOptions
instance.
-
tcpKeepAlive
public boolean tcpKeepAlive()- Returns:
- the configured value for the socket level tcpKeepAlive option.
-
tcpKeepAlive
Configures the TCP socket keep-alive value that should be used for a connection.- Parameters:
keepAlive
- The TCP/IP keep-alive value to use for the connection.- Returns:
- this
TransportOptions
instance.
-
connectTimeout
public int connectTimeout()- Returns:
- the configured value for the socket level connection timeout option.
-
connectTimeout
A transport layer connection timeout value that controls how long a connection attempt can block before giving up and throwing a connection error.- Parameters:
connectTimeout
- connection timeout in milliseconds.- Returns:
- this
TransportOptions
instance.
-
defaultTcpPort
public int defaultTcpPort()- Returns:
- the configured value for the socket level default port to use for connection if none is provided.
-
defaultTcpPort
The default unsecured connection port to use when none has been specified by the user.- Parameters:
defaultTcpPort
- the default port to use for non-SSL connection if none provided.- Returns:
- this
TransportOptions
instance.
-
localAddress
- Returns:
- the configured value for the socket level localAddress option.
-
localAddress
The local address to bind to when attempting a remote connection.- Parameters:
localAddress
- the local address to bind to.- Returns:
- this
TransportOptions
instance.
-
localPort
public int localPort()- Returns:
- the configured value for the socket level localPort option.
-
localPort
Configures the local port value to bind to when connecting to the remote, if that port is already in use this can lead to a connection error.- Parameters:
localPort
- local port value to use when making a remote connection.- Returns:
- this
TransportOptions
instance.
-
allowNativeIO
public boolean allowNativeIO()- Returns:
- true if an native IO library can be used if available on this platform instead of the JDK IO.
-
allowNativeIO
Determines if the a native IO implementation is preferred to the JDK based IO.- Parameters:
allowNativeIO
- should use of available native transport be allowed if one is available.- Returns:
- this
TransportOptions
instance.
-
nativeIOPreference
- Returns:
- the nativeIOPreference
-
nativeIOPreference
- Parameters:
nativeIOPreference
- the nativeIOPreference to set
-
traceBytes
public boolean traceBytes()- Returns:
- true if the transport should enable byte tracing
-
traceBytes
Determines if the transport should add a logger for bytes in / out- Parameters:
traceBytes
- should the transport log the bytes in and out.- Returns:
- this
TransportOptions
instance.
-
useWebSockets
public boolean useWebSockets()- Returns:
- the configured state of WebSockets for client connections.
-
useWebSockets
Set to true to configure the transport layer as a WebSocket based connection.- Parameters:
webSockets
- should the transport attempt connection using a WebSocket.- Returns:
- this
TransportOptions
instance.
-
webSocketPath
- Returns:
- the configured value for the socket level WebSocket path option.
-
webSocketPath
The optional path element to provide when connecting via a WebSocket.- Parameters:
webSocketPath
- path value to use for WebSocket connections.- Returns:
- this
TransportOptions
instance.
-
webSocketHeaders
- Returns:
- the configured value for the socket level WebSocket Headers option.
-
addWebSocketHeader
Additional headers to be passed along to the remote when performing a WebSocket based connect.- Parameters:
key
- the header key to use with the provided value.value
- the value to store under the provided key.- Returns:
- this
TransportOptions
instance.
-
webSocketMaxFrameSize
public int webSocketMaxFrameSize()- Returns:
- the configured value for the socket level WebSocket max frame size option.
-
webSocketMaxFrameSize
Configures the maximum size of each WebSocket frame, payloads larger than the max frame size are split into multiple frames during transmission.- Parameters:
maxFrameSize
- the maximum WebSocket frame size before payloads are split.- Returns:
- this
TransportOptions
instance.
-
webSocketCompression
public boolean webSocketCompression()- Returns:
- the configured value for the WebSocket compression support enabled flag.
-
webSocketCompression
Set to true to configure the transport layer as a WebSocket based connection that support compression of the WebSocket packets. This option simply allows the client to support compression if the server offers support but does not influence the server side, if the server does not offer support for compression of WS packets then this value has no affect on the WS packets and they remain uncompressed as if not enabled. (default is disabled).- Parameters:
enabled
- should the transport support WebSocket compression if server offers it.- Returns:
- this
TransportOptions
instance.
-
copyInto
Copy all configuration into the givenTransportOptions
from this instance.- Parameters:
other
- anotherTransportOptions
instance that will receive the configuration from this instance.- Returns:
- the options instance that was copied into.
-