Package org.apache.qpid.protonj2.client
Class ConnectionOptions
- java.lang.Object
-
- org.apache.qpid.protonj2.client.ConnectionOptions
-
public class ConnectionOptions extends java.lang.Object
Options that control the behaviour of theConnection
created from them.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CHANNEL_MAX
static long
DEFAULT_CLOSE_TIMEOUT
static java.util.List<java.lang.String>
DEFAULT_DESIRED_CAPABILITIES
static long
DEFAULT_DRAIN_TIMEOUT
static long
DEFAULT_IDLE_TIMEOUT
static int
DEFAULT_MAX_FRAME_SIZE
static long
DEFAULT_OPEN_TIMEOUT
static long
DEFAULT_REQUEST_TIMEOUT
static long
DEFAULT_SEND_TIMEOUT
static long
INFINITE
-
Constructor Summary
Constructors Constructor Description ConnectionOptions()
Create a newConnectionOptions
instance configured with default configuration settings.ConnectionOptions(ConnectionOptions options)
Creates aConnectionOptions
instance that is a copy of the given instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
channelMax()
ConnectionOptions
channelMax(int channelMax)
Configure the channel maximum value for the newConnection
created with these options.ConnectionOptions
clone()
long
closeTimeout()
ConnectionOptions
closeTimeout(long closeTimeout)
Configures the timeout used when awaiting a response from the remote that a request to close a resource such as aConnection
,Session
,Sender
orReceiver
h as been honored.ConnectionOptions
closeTimeout(long timeout, java.util.concurrent.TimeUnit units)
Configures the timeout used when awaiting a response from the remote that a request to close a resource such as aConnection
,Session
,Sender
orReceiver
h as been honored.java.util.function.BiConsumer<Connection,ConnectionEvent>
connectedHandler()
ConnectionOptions
connectedHandler(java.util.function.BiConsumer<Connection,ConnectionEvent> connectedHandler)
Configures a handler that will be notified when aConnection
has established.protected ConnectionOptions
copyInto(ConnectionOptions other)
Copy all options from thisConnectionOptions
instance into the instance provided.java.lang.String[]
desiredCapabilities()
ConnectionOptions
desiredCapabilities(java.lang.String... desiredCapabilities)
Sets the collection of capabilities to request from the remote for a newConnection
created using theseConnectionOptions
.java.util.function.BiConsumer<Connection,DisconnectionEvent>
disconnectedHandler()
ConnectionOptions
disconnectedHandler(java.util.function.BiConsumer<Connection,DisconnectionEvent> disconnectedHandler)
Configures a handler that will be notified when the connection has failed and cannot be recovered should reconnect be enabled.long
drainTimeout()
ConnectionOptions
drainTimeout(long drainTimeout)
Sets the drain timeout (in milliseconds) after which aReceiver
request to drain link credit is considered failed and the request will be marked as such.ConnectionOptions
drainTimeout(long timeout, java.util.concurrent.TimeUnit units)
Sets the drain timeout value after which aReceiver
request to drain link credit is considered failed and the request will be marked as such.long
idleTimeout()
ConnectionOptions
idleTimeout(long idleTimeout)
Sets the idle timeout (in milliseconds) after which the connection will be closed if the peer has not send any data.ConnectionOptions
idleTimeout(long timeout, java.util.concurrent.TimeUnit units)
Sets the idle timeout value after which the connection will be closed if the peer has not send any data.java.util.function.BiConsumer<Connection,DisconnectionEvent>
interruptedHandler()
ConnectionOptions
interruptedHandler(java.util.function.BiConsumer<Connection,DisconnectionEvent> interruptedHandler)
Configures a handler that will be notified when the currentConnection
experiences an interruption.int
maxFrameSize()
ConnectionOptions
maxFrameSize(int maxFrameSize)
Sets the max frame size (in bytes), values of -1 indicates to use the client selected default.java.lang.String[]
offeredCapabilities()
ConnectionOptions
offeredCapabilities(java.lang.String... offeredCapabilities)
Sets the collection of capabilities to offer to the remote from a newConnection
created using theseConnectionOptions
.long
openTimeout()
ConnectionOptions
openTimeout(long openTimeout)
Configures the timeout used when awaiting a response from the remote that a request to open a resource such as aConnection
,Session
,Sender
orReceiver
has been honored.ConnectionOptions
openTimeout(long timeout, java.util.concurrent.TimeUnit units)
Configures the timeout used when awaiting a response from the remote that a request to open a resource such as aConnection
,Session
,Sender
orReceiver
has been honored.java.lang.String
password()
ConnectionOptions
password(java.lang.String password)
Sets the password used when performing connection authentication.java.util.Map<java.lang.String,java.lang.Object>
properties()
ConnectionOptions
properties(java.util.Map<java.lang.String,java.lang.Object> properties)
Sets aMap
of properties to convey to the remote when a newConnection
is created from theseConnectionOptions
.java.util.function.BiConsumer<Connection,ConnectionEvent>
reconnectedHandler()
ConnectionOptions
reconnectedHandler(java.util.function.BiConsumer<Connection,ConnectionEvent> reconnectedHandler)
Configures a handler that will be notified when aConnection
that has previously experienced and interruption has been reconnected to a remote based on the reconnection configuration.boolean
reconnectEnabled()
ConnectionOptions
reconnectEnabled(boolean reconnectEnabled)
Controls if the connection will attempt to reconnect if unable to connect immediately or if an existing connection fails.ReconnectOptions
reconnectOptions()
long
requestTimeout()
ConnectionOptions
requestTimeout(long requestTimeout)
Configures the timeout used when awaiting a response from the remote that a request to perform some action such as starting a new transaction.ConnectionOptions
requestTimeout(long timeout, java.util.concurrent.TimeUnit units)
Configures the timeout used when awaiting a response from the remote that a request to perform some action such as starting a new transaction.SaslOptions
saslOptions()
long
sendTimeout()
ConnectionOptions
sendTimeout(long sendTimeout)
Configures the timeout used when awaiting a send operation to complete.ConnectionOptions
sendTimeout(long timeout, java.util.concurrent.TimeUnit units)
Configures the timeout used when awaiting a send operation to complete.boolean
sslEnabled()
ConnectionOptions
sslEnabled(boolean sslEnabled)
Controls if the connection will attempt to connect using a secure IO layer or not.SslOptions
sslOptions()
boolean
traceFrames()
ConnectionOptions
traceFrames(boolean traceFrames)
Configure if the newly created connection should enabled AMQP frame tracing to the system output.TransportOptions
transportOptions()
java.lang.String
user()
ConnectionOptions
user(java.lang.String user)
Sets the user name used when performing connection authentication.java.lang.String
virtualHost()
ConnectionOptions
virtualHost(java.lang.String virtualHost)
The virtual host value to provide to the remote when creating a newConnection
.
-
-
-
Field Detail
-
DEFAULT_DESIRED_CAPABILITIES
public static final java.util.List<java.lang.String> DEFAULT_DESIRED_CAPABILITIES
-
INFINITE
public static final long INFINITE
- See Also:
- Constant Field Values
-
DEFAULT_OPEN_TIMEOUT
public static final long DEFAULT_OPEN_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_CLOSE_TIMEOUT
public static final long DEFAULT_CLOSE_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_SEND_TIMEOUT
public static final long DEFAULT_SEND_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_REQUEST_TIMEOUT
public static final long DEFAULT_REQUEST_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_IDLE_TIMEOUT
public static final long DEFAULT_IDLE_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_DRAIN_TIMEOUT
public static final long DEFAULT_DRAIN_TIMEOUT
- See Also:
- Constant Field Values
-
DEFAULT_CHANNEL_MAX
public static final int DEFAULT_CHANNEL_MAX
- See Also:
- Constant Field Values
-
DEFAULT_MAX_FRAME_SIZE
public static final int DEFAULT_MAX_FRAME_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConnectionOptions
public ConnectionOptions()
Create a newConnectionOptions
instance configured with default configuration settings.
-
ConnectionOptions
public ConnectionOptions(ConnectionOptions options)
Creates aConnectionOptions
instance that is a copy of the given instance.- Parameters:
options
- TheConnectionOptions
instance whose configuration should be copied to this one.
-
-
Method Detail
-
clone
public ConnectionOptions clone()
- Overrides:
clone
in classjava.lang.Object
-
copyInto
protected ConnectionOptions copyInto(ConnectionOptions other)
Copy all options from thisConnectionOptions
instance into the instance provided.- Parameters:
other
- the target of this copy operation.- Returns:
- this
ConnectionOptions
instance.
-
closeTimeout
public long closeTimeout()
- Returns:
- the timeout used when awaiting a response from the remote when a resource is closed.
-
closeTimeout
public ConnectionOptions closeTimeout(long closeTimeout)
Configures the timeout used when awaiting a response from the remote that a request to close a resource such as aConnection
,Session
,Sender
orReceiver
h as been honored.- Parameters:
closeTimeout
- Timeout value in milliseconds to wait for a remote response.- Returns:
- this
ConnectionOptions
instance.
-
closeTimeout
public ConnectionOptions closeTimeout(long timeout, java.util.concurrent.TimeUnit units)
Configures the timeout used when awaiting a response from the remote that a request to close a resource such as aConnection
,Session
,Sender
orReceiver
h as been honored.- Parameters:
timeout
- Timeout value to wait for a remote response.units
- TheTimeUnit
that defines the timeout span.- Returns:
- this
ConnectionOptions
instance.
-
openTimeout
public long openTimeout()
- Returns:
- the timeout used when awaiting a response from the remote when a resource is opened.
-
openTimeout
public ConnectionOptions openTimeout(long openTimeout)
Configures the timeout used when awaiting a response from the remote that a request to open a resource such as aConnection
,Session
,Sender
orReceiver
has been honored.- Parameters:
openTimeout
- Timeout value in milliseconds to wait for a remote response.- Returns:
- this
ConnectionOptions
instance.
-
openTimeout
public ConnectionOptions openTimeout(long timeout, java.util.concurrent.TimeUnit units)
Configures the timeout used when awaiting a response from the remote that a request to open a resource such as aConnection
,Session
,Sender
orReceiver
has been honored.- Parameters:
timeout
- Timeout value to wait for a remote response.units
- TheTimeUnit
that defines the timeout span.- Returns:
- this
ConnectionOptions
instance.
-
sendTimeout
public long sendTimeout()
- Returns:
- the timeout used when awaiting a response from the remote when a resource is message send.
-
sendTimeout
public ConnectionOptions sendTimeout(long sendTimeout)
Configures the timeout used when awaiting a send operation to complete. A send will block if the remote has not granted theSender
or theSession
credit to do so, if the send blocks for longer than this timeout the send call will fail with anClientSendTimedOutException
exception to indicate that the send did not complete.- Parameters:
sendTimeout
- Timeout value in milliseconds to wait for a remote response.- Returns:
- this
ConnectionOptions
instance.
-
sendTimeout
public ConnectionOptions sendTimeout(long timeout, java.util.concurrent.TimeUnit units)
Configures the timeout used when awaiting a send operation to complete. A send will block if the remote has not granted theSender
or theSession
credit to do so, if the send blocks for longer than this timeout the send call will fail with anClientSendTimedOutException
exception to indicate that the send did not complete.- Parameters:
timeout
- Timeout value to wait for a remote response.units
- TheTimeUnit
that defines the timeout span.- Returns:
- this
ConnectionOptions
instance.
-
requestTimeout
public long requestTimeout()
- Returns:
- the timeout used when awaiting a response from the remote when a resource makes a request.
-
requestTimeout
public ConnectionOptions requestTimeout(long requestTimeout)
Configures the timeout used when awaiting a response from the remote that a request to perform some action such as starting a new transaction. If the remote does not respond within the configured timeout the resource making the request will mark it as failed and return an error to the request initiator usually in the form of aClientOperationTimedOutException
.- Parameters:
requestTimeout
- Timeout value in milliseconds to wait for a remote response.- Returns:
- this
ConnectionOptions
instance.
-
requestTimeout
public ConnectionOptions requestTimeout(long timeout, java.util.concurrent.TimeUnit units)
Configures the timeout used when awaiting a response from the remote that a request to perform some action such as starting a new transaction. If the remote does not respond within the configured timeout the resource making the request will mark it as failed and return an error to the request initiator usually in the form of aClientOperationTimedOutException
.- Parameters:
timeout
- Timeout value to wait for a remote response.units
- TheTimeUnit
that defines the timeout span.- Returns:
- this
ConnectionOptions
instance.
-
channelMax
public int channelMax()
- Returns:
- the configured or default channel max value for create
Connection
instances.
-
channelMax
public ConnectionOptions channelMax(int channelMax)
Configure the channel maximum value for the newConnection
created with these options.The channel max value controls how many
Session
instances can be created by a given Connection, the default value is 65535.- Parameters:
channelMax
- The channel max value to assign to newly createdConnection
instances.- Returns:
- this
ConnectionOptions
instance.
-
maxFrameSize
public int maxFrameSize()
- Returns:
- the configure maximum frame size value for newly create
Connection
instances.
-
maxFrameSize
public ConnectionOptions maxFrameSize(int maxFrameSize)
Sets the max frame size (in bytes), values of -1 indicates to use the client selected default.- Parameters:
maxFrameSize
- the frame size in bytes.- Returns:
- this
ConnectionOptions
instance.
-
idleTimeout
public long idleTimeout()
- Returns:
- the configured idle timeout value that will be sent to the remote.
-
idleTimeout
public ConnectionOptions idleTimeout(long idleTimeout)
Sets the idle timeout (in milliseconds) after which the connection will be closed if the peer has not send any data. The provided value will be halved before being transmitted as our advertised idle-timeout in the AMQPOpen
frame.- Parameters:
idleTimeout
- the timeout in milliseconds.- Returns:
- this
ConnectionOptions
instance.
-
idleTimeout
public ConnectionOptions idleTimeout(long timeout, java.util.concurrent.TimeUnit units)
Sets the idle timeout value after which the connection will be closed if the peer has not send any data. The provided value will be halved before being transmitted as our advertised idle-timeout in the AMQPOpen
frame.- Parameters:
timeout
- Timeout value to wait for a remote response.units
- TheTimeUnit
that defines the timeout span.- Returns:
- this
ConnectionOptions
instance.
-
drainTimeout
public long drainTimeout()
- Returns:
- the configured drain timeout value that will use to fail a pending drain request.
-
drainTimeout
public ConnectionOptions drainTimeout(long drainTimeout)
Sets the drain timeout (in milliseconds) after which aReceiver
request to drain link credit is considered failed and the request will be marked as such.- Parameters:
drainTimeout
- the drainTimeout to use for receiver links.- Returns:
- this
ConnectionOptions
instance.
-
drainTimeout
public ConnectionOptions drainTimeout(long timeout, java.util.concurrent.TimeUnit units)
Sets the drain timeout value after which aReceiver
request to drain link credit is considered failed and the request will be marked as such.- Parameters:
timeout
- Timeout value to wait for a remote response.units
- TheTimeUnit
that defines the timeout span.- Returns:
- this
ConnectionOptions
instance.
-
offeredCapabilities
public java.lang.String[] offeredCapabilities()
- Returns:
- the offeredCapabilities that have been configured.
-
offeredCapabilities
public ConnectionOptions offeredCapabilities(java.lang.String... offeredCapabilities)
Sets the collection of capabilities to offer to the remote from a newConnection
created using theseConnectionOptions
. The offered capabilities advertise to the remote capabilities that thisConnection
supports.- Parameters:
offeredCapabilities
- the offeredCapabilities to set on a newConnection
.- Returns:
- this
ConnectionOptions
instance.
-
desiredCapabilities
public java.lang.String[] desiredCapabilities()
- Returns:
- the desiredCapabilities that have been configured.
-
desiredCapabilities
public ConnectionOptions desiredCapabilities(java.lang.String... desiredCapabilities)
Sets the collection of capabilities to request from the remote for a newConnection
created using theseConnectionOptions
. The desired capabilities inform the remote peer of the various capabilities the newConnection
requires and the remote should return those that it supports in its offered capabilities.- Parameters:
desiredCapabilities
- the desiredCapabilities to set on a newConnection
.- Returns:
- this
ConnectionOptions
instance.
-
properties
public java.util.Map<java.lang.String,java.lang.Object> properties()
- Returns:
- the properties that have been configured.
-
properties
public ConnectionOptions properties(java.util.Map<java.lang.String,java.lang.Object> properties)
Sets aMap
of properties to convey to the remote when a newConnection
is created from theseConnectionOptions
.- Parameters:
properties
- the properties to set- Returns:
- this
ConnectionOptions
instance.
-
virtualHost
public java.lang.String virtualHost()
- Returns:
- the virtual host value configured.
-
virtualHost
public ConnectionOptions virtualHost(java.lang.String virtualHost)
The virtual host value to provide to the remote when creating a newConnection
.- Parameters:
virtualHost
- the virtual host to set- Returns:
- this
ConnectionOptions
instance.
-
user
public java.lang.String user()
- Returns:
- the user name that is configured for new
Connection
instances.
-
user
public ConnectionOptions user(java.lang.String user)
Sets the user name used when performing connection authentication.- Parameters:
user
- the user to set- Returns:
- this
ConnectionOptions
instance.
-
password
public java.lang.String password()
- Returns:
- the password that is configured for new
Connection
instances.
-
password
public ConnectionOptions password(java.lang.String password)
Sets the password used when performing connection authentication.- Parameters:
password
- the password to set- Returns:
- this
ConnectionOptions
instance.
-
transportOptions
public TransportOptions transportOptions()
- Returns:
- the transport options that will be used for the
Connection
.
-
sslOptions
public SslOptions sslOptions()
- Returns:
- the SSL options that will be used for the
Connection
.
-
saslOptions
public SaslOptions saslOptions()
- Returns:
- the SASL options that will be used for the
Connection
.
-
reconnectEnabled
public boolean reconnectEnabled()
- Returns:
- true if reconnection support has been enabled for this connection.
-
reconnectEnabled
public ConnectionOptions reconnectEnabled(boolean reconnectEnabled)
Controls if the connection will attempt to reconnect if unable to connect immediately or if an existing connection fails.This option enables or disables reconnection to a remote remote peer after IO errors. To control specifics of the reconnection configuration for the
Connection
the values must be updated in theReconnectOptions
configuration prior to creating the connection.- Parameters:
reconnectEnabled
- Controls if reconnection is enabled or not for the associatedConnection
.- Returns:
- this options instance.
-
reconnectOptions
public ReconnectOptions reconnectOptions()
- Returns:
- the reconnection options that will be used for the
Connection
.
-
traceFrames
public ConnectionOptions traceFrames(boolean traceFrames)
Configure if the newly created connection should enabled AMQP frame tracing to the system output.- Parameters:
traceFrames
- true if frame tracing on this connection should be enabled.- Returns:
- this
ConnectionOptions
instance.
-
traceFrames
public boolean traceFrames()
- Returns:
- true if the connection is configured to perform frame tracing.
-
sslEnabled
public boolean sslEnabled()
- Returns:
- true if SSL support has been enabled for this connection.
-
sslEnabled
public ConnectionOptions sslEnabled(boolean sslEnabled)
Controls if the connection will attempt to connect using a secure IO layer or not.This option enables or disables SSL encryption when connecting to a remote peer. To control specifics of the SSL configuration for the
Connection
the values must be updated in theSslOptions
configuration prior to creating the connection.- Parameters:
sslEnabled
- Is SSL encryption enabled for theConnection
.- Returns:
- this
ConnectionOptions
instance.
-
disconnectedHandler
public java.util.function.BiConsumer<Connection,DisconnectionEvent> disconnectedHandler()
- Returns:
- the connection failed handler currently registered.
-
disconnectedHandler
public ConnectionOptions disconnectedHandler(java.util.function.BiConsumer<Connection,DisconnectionEvent> disconnectedHandler)
Configures a handler that will be notified when the connection has failed and cannot be recovered should reconnect be enabled. Once notified of the failure theConnection
is no longer operable and theConnection
APIs will throw an exception to indicate that the connection has failed. The client application should close a failedConnection
once it becomes aware of the failure to ensure all connection resources are cleaned up properly.- Parameters:
disconnectedHandler
- the connection failed handler to notify when the connection fails for any reason.- Returns:
- this
ConnectionOptions
instance. - See Also:
interruptedHandler
,connectedHandler
,disconnectedHandler
-
connectedHandler
public java.util.function.BiConsumer<Connection,ConnectionEvent> connectedHandler()
- Returns:
- the connection established handler that is currently registered
-
connectedHandler
public ConnectionOptions connectedHandler(java.util.function.BiConsumer<Connection,ConnectionEvent> connectedHandler)
Configures a handler that will be notified when aConnection
has established. This handler is called for each connection event when reconnection is enabled unless areconnectedHandler
is configured in which case this handler is only notified on the first connection to a remote.- Parameters:
connectedHandler
- the connection established handler to assign to theseConnectionOptions
.- Returns:
- this
ConnectionOptions
instance. - See Also:
disconnectedHandler()
,interruptedHandler
,reconnectedHandler
-
interruptedHandler
public java.util.function.BiConsumer<Connection,DisconnectionEvent> interruptedHandler()
- Returns:
- the connection interrupted handler that is currently registered
-
interruptedHandler
public ConnectionOptions interruptedHandler(java.util.function.BiConsumer<Connection,DisconnectionEvent> interruptedHandler)
Configures a handler that will be notified when the currentConnection
experiences an interruption. TheConnection
will only signal this handler when the reconnection feature is enabled and will follow this event either with a notification that the connection has been restored (if a handler is registered), or with a notification that the connection has failed if the reconnection configuration places limits on the the number of reconnection attempts.- Parameters:
interruptedHandler
- the connection interrupted handler to assign to theseConnectionOptions
.- Returns:
- this
ReconnectOptions
instance. - See Also:
connectedHandler
,reconnectedHandler
,disconnectedHandler
-
reconnectedHandler
public java.util.function.BiConsumer<Connection,ConnectionEvent> reconnectedHandler()
- Returns:
- the connection restored handler that is currently registered
-
reconnectedHandler
public ConnectionOptions reconnectedHandler(java.util.function.BiConsumer<Connection,ConnectionEvent> reconnectedHandler)
Configures a handler that will be notified when aConnection
that has previously experienced and interruption has been reconnected to a remote based on the reconnection configuration.- Parameters:
reconnectedHandler
- the connection restored handler to assign to theseConnectionOptions
.- Returns:
- this
ReconnectOptions
instance. - See Also:
connectedHandler
,interruptedHandler
,disconnectedHandler
-
-