Class ClientConfigProperties
- java.lang.Object
-
- org.eclipse.hono.config.AbstractConfig
-
- org.eclipse.hono.config.AuthenticatingClientConfigProperties
-
- org.eclipse.hono.config.ClientConfigProperties
-
public class ClientConfigProperties extends AuthenticatingClientConfigProperties
Common configuration properties required for accessing an AMQP 1.0 container.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_CONNECT_TIMEOUT
The default amount of time (milliseconds) to wait for an AMQP connection to be opened.static long
DEFAULT_FLOW_LATENCY
The default amount of time (milliseconds) to wait for credits after link creation.static int
DEFAULT_IDLE_TIMEOUT
The default amount of time (milliseconds) after which a connection will be closed when no frames have been received from the remote peer.static int
DEFAULT_INITIAL_CREDITS
The default number of credits issued by the receiver side of a link.static long
DEFAULT_LINK_ESTABLISHMENT_TIMEOUT
The default amount of time (milliseconds) to wait for the remote peer's attach frame during link establishment.static int
DEFAULT_RECONNECT_DELAY_INCREMENT
The default amount of time (milliseconds) that the delay before trying to re-establish an AMQP connection with the peer will be increased by with each successive attempt.static int
DEFAULT_RECONNECT_MAX_DELAY
The default maximum amount of time (milliseconds) to wait before trying to re-establish an AMQP connection with the peer.static int
DEFAULT_RECONNECT_MIN_DELAY
The default minimum amount of time (milliseconds) to wait before trying to re-establish an AMQP connection with the peer.static long
DEFAULT_REQUEST_TIMEOUT
The default amount of time (milliseconds) to wait for a response before a request times out.static long
DEFAULT_SEND_MESSAGE_TIMEOUT
The default amount of time (milliseconds) to wait for a delivery update after a message was sent.-
Fields inherited from class org.eclipse.hono.config.AuthenticatingClientConfigProperties
SERVER_ROLE_UNKNOWN
-
Fields inherited from class org.eclipse.hono.config.AbstractConfig
LOG
-
-
Constructor Summary
Constructors Constructor Description ClientConfigProperties()
Creates new properties with default values.ClientConfigProperties(ClientConfigProperties otherProperties)
Creates properties based on other properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pattern
getAddressRewritePattern()
Gets precompiled address rewrite pattern.String
getAddressRewriteReplacement()
Gets address rewrite replacement.String
getAddressRewriteRule()
Gets the rewrite rule for downstream addresses.String
getAmqpHostname()
Gets the name being indicated as the hostname in the client's AMQP Open frame.int
getConnectTimeout()
Gets the maximum amount of time a client should wait for an AMQP connection with a peer to be opened.long
getFlowLatency()
Gets the maximum amount of time that a client should wait for credits after sender link creation.int
getHeartbeatInterval()
Gets the interval in milliseconds in which frames are sent to the remote peer to check that the connection is still alive.int
getIdleTimeout()
Gets the amount of time in milliseconds after which a connection will be closed when no frames have been received from the remote peer.int
getInitialCredits()
Gets the number of initial credits, that will be given from a receiver to a sender at link creation.long
getLinkEstablishmentTimeout()
Gets the maximum amount of time that a client waits for the establishment of a link with a peer.String
getName()
Gets the name being indicated as part of the container-id in the client's AMQP Open frame.int
getReconnectAttempts()
Gets the number of attempts (in addition to the original connection attempt) that the client should make in order to establish an AMQP connection with the peer before giving up.long
getReconnectDelayIncrement()
Gets the factor used in the exponential backoff algorithm for determining the delay before trying to re-establish an AMQP connection with the peer.long
getReconnectMaxDelay()
Gets the maximum amount of time to wait before trying to re-establish an AMQP connection with the peer.long
getReconnectMinDelay()
Gets the minimum amount of time to wait before trying to re-establish an AMQP connection with the peer.long
getRequestTimeout()
Gets the maximum amount of time a client should wait for a response to a request before the request is failed.long
getSendMessageTimeout()
Gets the maximum amount of time a client should wait for a delivery update after sending an event or command message.void
setAddressRewriteRule(String addressRewriteRule)
Sets the rewrite rule for downstream addresses.void
setAmqpHostname(String amqpHostname)
Sets the name to indicate as the hostname in the client's AMQP Open frame.void
setConnectTimeout(int connectTimeoutMillis)
Sets the maximum amount of time a client should wait for an AMQP connection with a peer to be opened.void
setFlowLatency(long latency)
Sets the maximum amount of time that a client should wait for credits after sender link creation.void
setIdleTimeout(int idleTimeoutMillis)
Sets the amount of time in milliseconds after which a connection will be closed when no frames have been received from the remote peer.void
setInitialCredits(int initialCredits)
Sets the number of initial credits, that will be given from a receiver to a sender at link creation.void
setLinkEstablishmentTimeout(long latency)
Sets the maximum amount of time that a client should wait for the establishment of a link with a peer.void
setName(String name)
Sets the name to indicate as part of the container-id in the client's AMQP Open frame.void
setReconnectAttempts(int attempts)
Sets the number of attempts (in addition to the original connection attempt) that the client should make in order to establish an AMQP connection with the peer before giving up.void
setReconnectDelayIncrement(long reconnectDelayIncrement)
Sets the factor used in the exponential backoff algorithm for determining the delay before trying to re-establish an AMQP connection with the peer.void
setReconnectMaxDelay(long reconnectMaxDelay)
Sets the maximum amount of time to wait before trying to re-establish an AMQP connection with the peer.void
setReconnectMinDelay(long reconnectMinDelay)
Sets the minimum amount of time to wait before trying to re-establish an AMQP connection with the peer.void
setRequestTimeout(long requestTimeoutMillis)
Sets the maximum amount of time a client should wait for a response to a request before the request is failed.void
setSendMessageTimeout(long sendMessageTimeoutMillis)
Sets the maximum amount of time a client should wait for a delivery update after sending an event or command message.-
Methods inherited from class org.eclipse.hono.config.AuthenticatingClientConfigProperties
getCredentialsPath, getHost, getPassword, getPort, getServerRole, getUsername, isHostnameVerificationRequired, isTlsEnabled, setCredentialsPath, setHost, setHostnameVerificationRequired, setPassword, setPort, setServerRole, setTlsEnabled, setUsername
-
Methods inherited from class org.eclipse.hono.config.AbstractConfig
getCertPath, getKeyCertOptions, getKeyFormat, getKeyPath, getKeyStorePassword, getKeyStorePath, getPathSeparator, getSecureProtocols, getTrustOptions, getTrustStoreFormat, getTrustStorePassword, getTrustStorePath, isValidPort, setCertPath, setKeyFormat, setKeyPath, setKeyStorePassword, setKeyStorePath, setPathSeparator, setSecureProtocols, setTrustStoreFormat, setTrustStorePassword, setTrustStorePath
-
-
-
-
Field Detail
-
DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_CONNECT_TIMEOUT
The default amount of time (milliseconds) to wait for an AMQP connection to be opened.- See Also:
- Constant Field Values
-
DEFAULT_FLOW_LATENCY
public static final long DEFAULT_FLOW_LATENCY
The default amount of time (milliseconds) to wait for credits after link creation.- See Also:
- Constant Field Values
-
DEFAULT_IDLE_TIMEOUT
public static final int DEFAULT_IDLE_TIMEOUT
The default amount of time (milliseconds) after which a connection will be closed when no frames have been received from the remote peer.- See Also:
- Constant Field Values
-
DEFAULT_INITIAL_CREDITS
public static final int DEFAULT_INITIAL_CREDITS
The default number of credits issued by the receiver side of a link.- See Also:
- Constant Field Values
-
DEFAULT_LINK_ESTABLISHMENT_TIMEOUT
public static final long DEFAULT_LINK_ESTABLISHMENT_TIMEOUT
The default amount of time (milliseconds) to wait for the remote peer's attach frame during link establishment.- See Also:
- Constant Field Values
-
DEFAULT_RECONNECT_MIN_DELAY
public static final int DEFAULT_RECONNECT_MIN_DELAY
The default minimum amount of time (milliseconds) to wait before trying to re-establish an AMQP connection with the peer.- See Also:
- Constant Field Values
-
DEFAULT_RECONNECT_MAX_DELAY
public static final int DEFAULT_RECONNECT_MAX_DELAY
The default maximum amount of time (milliseconds) to wait before trying to re-establish an AMQP connection with the peer.- See Also:
- Constant Field Values
-
DEFAULT_RECONNECT_DELAY_INCREMENT
public static final int DEFAULT_RECONNECT_DELAY_INCREMENT
The default amount of time (milliseconds) that the delay before trying to re-establish an AMQP connection with the peer will be increased by with each successive attempt.- See Also:
- Constant Field Values
-
DEFAULT_REQUEST_TIMEOUT
public static final long DEFAULT_REQUEST_TIMEOUT
The default amount of time (milliseconds) to wait for a response before a request times out.- See Also:
- Constant Field Values
-
DEFAULT_SEND_MESSAGE_TIMEOUT
public static final long DEFAULT_SEND_MESSAGE_TIMEOUT
The default amount of time (milliseconds) to wait for a delivery update after a message was sent.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ClientConfigProperties
public ClientConfigProperties()
Creates new properties with default values.
-
ClientConfigProperties
public ClientConfigProperties(ClientConfigProperties otherProperties)
Creates properties based on other properties.- Parameters:
otherProperties
- The properties to copy.
-
-
Method Detail
-
getName
public final String getName()
Gets the name being indicated as part of the container-id in the client's AMQP Open frame.- Returns:
- The name or
null
if no name has been set.
-
setName
public final void setName(String name)
Sets the name to indicate as part of the container-id in the client's AMQP Open frame.- Parameters:
name
- The name to set.
-
getAmqpHostname
public final String getAmqpHostname()
Gets the name being indicated as the hostname in the client's AMQP Open frame.- Returns:
- The host name or
null
if no host name has been set.
-
setAmqpHostname
public final void setAmqpHostname(String amqpHostname)
Sets the name to indicate as the hostname in the client's AMQP Open frame.- Parameters:
amqpHostname
- The host name to set.
-
getFlowLatency
public final long getFlowLatency()
Gets the maximum amount of time that a client should wait for credits after sender link creation.The AMQP 1.0 protocol requires the receiver side of a link to explicitly send a flow frame containing credits granted to the sender after the link has been established.
This property can be used to tune the time period to wait according to the network latency involved with the communication link between the client and the service.
The default value of this property is
DEFAULT_FLOW_LATENCY
.- Returns:
- The number of milliseconds to wait.
-
setFlowLatency
public final void setFlowLatency(long latency)
Sets the maximum amount of time that a client should wait for credits after sender link creation.The AMQP 1.0 protocol requires the receiver side of a link to explicitly send a flow frame containing credits granted to the sender after the link has been established.
This property can be used to tune the time period to wait according to the network latency involved with the communication link between the client and the service.
The default value of this property is
DEFAULT_FLOW_LATENCY
.- Parameters:
latency
- The number of milliseconds to wait.- Throws:
IllegalArgumentException
- if latency is negative.
-
getLinkEstablishmentTimeout
public final long getLinkEstablishmentTimeout()
Gets the maximum amount of time that a client waits for the establishment of a link with a peer.The AMQP 1.0 protocol defines that a link is established once both peers have exchanged their attach frames. The value of this property defines how long the client should wait for the peer's attach frame before considering the attempt to establish the link failed.
This property can be used to tune the time period to wait according to the network latency involved with the communication link between the client and the service.
The default value of this property is
DEFAULT_LINK_ESTABLISHMENT_TIMEOUT
.- Returns:
- The number of milliseconds to wait.
-
setLinkEstablishmentTimeout
public final void setLinkEstablishmentTimeout(long latency)
Sets the maximum amount of time that a client should wait for the establishment of a link with a peer.The AMQP 1.0 protocol defines that a link is established once both peers have exchanged their attach frames. The value of this property defines how long the client should wait for the peer's attach frame before considering the attempt to establish the link failed.
This property can be used to tune the time period to wait according to the network latency involved with the communication link between the client and the service.
The default value of this property is
DEFAULT_FLOW_LATENCY
.- Parameters:
latency
- The number of milliseconds to wait.- Throws:
IllegalArgumentException
- if latency is negative.
-
getInitialCredits
public final int getInitialCredits()
Gets the number of initial credits, that will be given from a receiver to a sender at link creation.The default value of this property is
DEFAULT_INITIAL_CREDITS
.- Returns:
- The number of initial credits.
-
setInitialCredits
public final void setInitialCredits(int initialCredits)
Sets the number of initial credits, that will be given from a receiver to a sender at link creation.The default value of this property is
DEFAULT_INITIAL_CREDITS
.- Parameters:
initialCredits
- The initial credits to set.- Throws:
IllegalArgumentException
- if the number is negative.
-
getSendMessageTimeout
public final long getSendMessageTimeout()
Gets the maximum amount of time a client should wait for a delivery update after sending an event or command message. If no delivery update is received in that time, the future with the outcome of the send operation will be failed.The default value of this property is
DEFAULT_SEND_MESSAGE_TIMEOUT
.- Returns:
- The maximum number of milliseconds to wait.
-
setSendMessageTimeout
public final void setSendMessageTimeout(long sendMessageTimeoutMillis)
Sets the maximum amount of time a client should wait for a delivery update after sending an event or command message. If no delivery update is received in that time, the future with the outcome of the send operation will be failed.The default value of this property is
DEFAULT_SEND_MESSAGE_TIMEOUT
.- Parameters:
sendMessageTimeoutMillis
- The maximum number of milliseconds to wait.- Throws:
IllegalArgumentException
- if timeout is negative.
-
getRequestTimeout
public final long getRequestTimeout()
Gets the maximum amount of time a client should wait for a response to a request before the request is failed.The default value of this property is
DEFAULT_REQUEST_TIMEOUT
.- Returns:
- The maximum number of milliseconds to wait.
-
setRequestTimeout
public final void setRequestTimeout(long requestTimeoutMillis)
Sets the maximum amount of time a client should wait for a response to a request before the request is failed.The default value of this property is
DEFAULT_REQUEST_TIMEOUT
.- Parameters:
requestTimeoutMillis
- The maximum number of milliseconds to wait.- Throws:
IllegalArgumentException
- if request timeout is negative.
-
getReconnectAttempts
public int getReconnectAttempts()
Gets the number of attempts (in addition to the original connection attempt) that the client should make in order to establish an AMQP connection with the peer before giving up.The default value of this property is -1 which means that the client will try forever.
- Returns:
- The number of attempts.
-
setReconnectAttempts
public void setReconnectAttempts(int attempts)
Sets the number of attempts (in addition to the original connection attempt) that the client should make in order to establish an AMQP connection with the peer before giving up.The default value of this property is -1 which means that the client will try forever.
- Parameters:
attempts
- The number of attempts to make.- Throws:
IllegalArgumentException
- if attempts is < -1.
-
getReconnectMinDelay
public long getReconnectMinDelay()
Gets the minimum amount of time to wait before trying to re-establish an AMQP connection with the peer.The default value of this property is 0.
- Returns:
- The minimum delay in milliseconds.
-
setReconnectMinDelay
public void setReconnectMinDelay(long reconnectMinDelay)
Sets the minimum amount of time to wait before trying to re-establish an AMQP connection with the peer.The default value of this property is 0.
- Parameters:
reconnectMinDelay
- The minimum delay in milliseconds.- Throws:
IllegalArgumentException
- if reconnectMinDelay is < 0.
-
getReconnectMaxDelay
public long getReconnectMaxDelay()
Gets the maximum amount of time to wait before trying to re-establish an AMQP connection with the peer.The default value of this property is 7000ms.
- Returns:
- The maximum delay in milliseconds.
-
setReconnectMaxDelay
public void setReconnectMaxDelay(long reconnectMaxDelay)
Sets the maximum amount of time to wait before trying to re-establish an AMQP connection with the peer.The default value of this property is 7000ms.
- Parameters:
reconnectMaxDelay
- The maximum delay in milliseconds.- Throws:
IllegalArgumentException
- if reconnectMaxDelay is < 0.
-
getReconnectDelayIncrement
public long getReconnectDelayIncrement()
Gets the factor used in the exponential backoff algorithm for determining the delay before trying to re-establish an AMQP connection with the peer.The default value of this property is 100ms.
- Returns:
- The value to exponentially increase the delay by in milliseconds.
-
setReconnectDelayIncrement
public void setReconnectDelayIncrement(long reconnectDelayIncrement)
Sets the factor used in the exponential backoff algorithm for determining the delay before trying to re-establish an AMQP connection with the peer.The default value of this property is 100ms.
- Parameters:
reconnectDelayIncrement
- The value to exponentially increase the delay by in milliseconds.- Throws:
IllegalArgumentException
- if reconnectDelayIncrement is < 0.
-
getConnectTimeout
public final int getConnectTimeout()
Gets the maximum amount of time a client should wait for an AMQP connection with a peer to be opened.This includes the time for TCP/TLS connection establishment, SASL handshake and exchange of the AMQP open frame.
The default value of this property is
DEFAULT_CONNECT_TIMEOUT
.- Returns:
- The maximum number of milliseconds to wait.
-
setConnectTimeout
public final void setConnectTimeout(int connectTimeoutMillis)
Sets the maximum amount of time a client should wait for an AMQP connection with a peer to be opened.This includes the time for TCP/TLS connection establishment, SASL handshake and exchange of the AMQP open frame.
The default value of this property is
DEFAULT_CONNECT_TIMEOUT
.- Parameters:
connectTimeoutMillis
- The maximum number of milliseconds to wait.- Throws:
IllegalArgumentException
- if connect timeout is negative.
-
getHeartbeatInterval
public final int getHeartbeatInterval()
Gets the interval in milliseconds in which frames are sent to the remote peer to check that the connection is still alive.This value is set to be half of
getIdleTimeout()
.- Returns:
- The heartbeatInterval in milliseconds.
-
getIdleTimeout
public final int getIdleTimeout()
Gets the amount of time in milliseconds after which a connection will be closed when no frames have been received from the remote peer.This property is also used to configure a heartbeat mechanism, checking that the connection is still alive. The corresponding heartbeat interval will be set to idleTimeout/2 ms.
The default value of this property is
DEFAULT_IDLE_TIMEOUT
.- Returns:
- The idleTimeout in milliseconds.
-
setIdleTimeout
public final void setIdleTimeout(int idleTimeoutMillis)
Sets the amount of time in milliseconds after which a connection will be closed when no frames have been received from the remote peer.This property is also used to configure a heartbeat mechanism, checking that the connection is still alive. The corresponding heartbeat interval will be set to idleTimeout/2 ms.
The default value of this property is
DEFAULT_IDLE_TIMEOUT
.- Parameters:
idleTimeoutMillis
- The idleTimeout in milliseconds.- Throws:
IllegalArgumentException
- if idleTimeout is negative.
-
getAddressRewriteRule
public final String getAddressRewriteRule()
Gets the rewrite rule for downstream addresses. SeeAddressHelper.rewrite(String, ClientConfigProperties)
for more information about syntax and behavior of this property.- Returns:
- The rewrite rule to be applied to the address.
-
setAddressRewriteRule
public final void setAddressRewriteRule(String addressRewriteRule)
Sets the rewrite rule for downstream addresses. This method parses the rule and tries to precompile the pattern to be used. The pattern and replacement can be obtained bygetAddressRewritePattern()
andgetAddressRewriteReplacement()
methods. For more information about syntax and behavior of this property seeAddressHelper.rewrite(String, ClientConfigProperties)
method.- Parameters:
addressRewriteRule
- The rewrite rule to be applied to the address.
-
getAddressRewritePattern
public final Pattern getAddressRewritePattern()
Gets precompiled address rewrite pattern.- Returns:
- The precompiled address rewrite pattern.
-
getAddressRewriteReplacement
public final String getAddressRewriteReplacement()
Gets address rewrite replacement.- Returns:
- The address rewrite replacement.
-
-