Package com.plccom.mqtt.client
Class PlccomMqttClientOptions
- java.lang.Object
-
- com.plccom.mqtt.client.PlccomMqttClientOptions
-
public final class PlccomMqttClientOptions extends Object
Immutable options for a PLCcom MQTT client connection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPlccomMqttClientOptions.BuilderBuilder forPlccomMqttClientOptions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PlccomMqttClientOptions.Builderbuilder(PlccomMqttEndpoint endpoint)Creates a builder for the given endpoint.StringgetClientId()Returns the MQTT client identifier.longgetConnectTimeoutMillis()Returns the socket connect timeout.PlccomMqttDiagnosticLevelgetDiagnosticLevel()Returns the minimum diagnostic level delivered to the configured listener.PlccomMqttDiagnosticListenergetDiagnosticListener()Returns the optional diagnostic listener.PlccomMqttEndpointgetEndpoint()Returns the broker endpoint.byte[]getEnhancedAuthenticationData()Returns a defensive copy of the initial MQTT 5 enhanced Authentication Data sent in CONNECT.StringgetEnhancedAuthenticationMethod()Returns the MQTT 5 enhanced Authentication Method sent in CONNECT.PlccomMqttClientEnhancedAuthenticatorgetEnhancedAuthenticator()Returns the optional client-side enhanced authentication handler.intgetKeepAliveSeconds()Returns the keep-alive interval sent in CONNECT.PlccomMqttLastWillgetLastWill()Returns the optional MQTT Last Will configuration.PlccomMqttLimitsgetLimits()Returns the configured safety limits.InetAddressgetLocalAddress()Returns the optional local address for the outgoing MQTT socket.longgetOperationTimeoutMillis()Returns the timeout for blocking MQTT operations.byte[]getPasswordBytes()Returns a defensive copy of the optional MQTT password bytes.PlccomMqttProtocolVersiongetProtocolVersion()Returns the requested MQTT protocol selection.longgetReconnectInitialDelayMillis()Returns the initial reconnect delay.longgetReconnectMaxDelayMillis()Returns the maximum reconnect delay.LonggetSessionExpiryIntervalSeconds()Returns the MQTT 5 session expiry interval.intgetSocketReadTimeoutMillis()Returns the socket read timeout used by the reader loop.PlccomMqttTlsOptionsgetTlsOptions()Returns the TLS options.intgetTopicAliasMaximum()Returns the MQTT 5 Topic Alias Maximum advertised by this client.StringgetUsername()Returns the optional MQTT username.booleanhasEnhancedAuthentication()Returns whether MQTT 5 enhanced authentication is configured.booleanisAutomaticReconnect()Returns whether failed operations may trigger automatic reconnect.booleanisCleanStart()Returns whether the client requests a clean MQTT session.
-
-
-
Method Detail
-
builder
public static PlccomMqttClientOptions.Builder builder(PlccomMqttEndpoint endpoint)
Creates a builder for the given endpoint.- Parameters:
endpoint- MQTT endpoint- Returns:
- builder
- Throws:
NullPointerException- ifendpointisnullduringPlccomMqttClientOptions.Builder.build()
-
getEndpoint
public PlccomMqttEndpoint getEndpoint()
Returns the broker endpoint.- Returns:
- MQTT endpoint used for socket creation
-
getClientId
public String getClientId()
Returns the MQTT client identifier.- Returns:
- non-empty client identifier
-
getProtocolVersion
public PlccomMqttProtocolVersion getProtocolVersion()
Returns the requested MQTT protocol selection.- Returns:
- requested protocol version, possibly
PlccomMqttProtocolVersion.AUTO
-
isCleanStart
public boolean isCleanStart()
Returns whether the client requests a clean MQTT session.- Returns:
truewhen the CONNECT packet should request a clean start
-
getSessionExpiryIntervalSeconds
public Long getSessionExpiryIntervalSeconds()
Returns the MQTT 5 session expiry interval.- Returns:
- session expiry in seconds, or
nullto omit the property
-
getKeepAliveSeconds
public int getKeepAliveSeconds()
Returns the keep-alive interval sent in CONNECT.- Returns:
- keep-alive interval in seconds
-
getLastWill
public PlccomMqttLastWill getLastWill()
Returns the optional MQTT Last Will configuration.- Returns:
- Last Will configuration, or
nullwhen CONNECT should not declare a Will
-
getUsername
public String getUsername()
Returns the optional MQTT username.- Returns:
- username, or
nullwhen no username should be sent
-
getPasswordBytes
public byte[] getPasswordBytes()
Returns a defensive copy of the optional MQTT password bytes.- Returns:
- password bytes, or
nullwhen no password should be sent
-
getEnhancedAuthenticationMethod
public String getEnhancedAuthenticationMethod()
Returns the MQTT 5 enhanced Authentication Method sent in CONNECT.- Returns:
- authentication method, or
nullwhen enhanced authentication is disabled
-
getEnhancedAuthenticationData
public byte[] getEnhancedAuthenticationData()
Returns a defensive copy of the initial MQTT 5 enhanced Authentication Data sent in CONNECT.- Returns:
- initial authentication data, or
nullwhen none is sent
-
getEnhancedAuthenticator
public PlccomMqttClientEnhancedAuthenticator getEnhancedAuthenticator()
Returns the optional client-side enhanced authentication handler.- Returns:
- enhanced authenticator, or
nullwhen the client will not answer broker AUTH challenges
-
hasEnhancedAuthentication
public boolean hasEnhancedAuthentication()
Returns whether MQTT 5 enhanced authentication is configured.- Returns:
truewhen a method, initial data or handler is configured
-
getTopicAliasMaximum
public int getTopicAliasMaximum()
Returns the MQTT 5 Topic Alias Maximum advertised by this client.A value of
0means the client does not accept inbound Topic Aliases from the broker and omits the CONNECT property. A positive value allows the broker to use aliases from1through this maximum on this connection.- Returns:
- configured MQTT 5 Topic Alias Maximum in the range
0..65535
-
getTlsOptions
public PlccomMqttTlsOptions getTlsOptions()
Returns the TLS options.- Returns:
- TLS options, never
null
-
getLimits
public PlccomMqttLimits getLimits()
Returns the configured safety limits.- Returns:
- packet, topic and queue limits
-
getConnectTimeoutMillis
public long getConnectTimeoutMillis()
Returns the socket connect timeout.- Returns:
- connect timeout in milliseconds
-
getOperationTimeoutMillis
public long getOperationTimeoutMillis()
Returns the timeout for blocking MQTT operations.- Returns:
- operation timeout in milliseconds
-
getSocketReadTimeoutMillis
public int getSocketReadTimeoutMillis()
Returns the socket read timeout used by the reader loop.- Returns:
- read timeout in milliseconds
-
getLocalAddress
public InetAddress getLocalAddress()
Returns the optional local address for the outgoing MQTT socket.- Returns:
- local bind address, or
nullwhen the operating system selects the outgoing interface
-
isAutomaticReconnect
public boolean isAutomaticReconnect()
Returns whether failed operations may trigger automatic reconnect.- Returns:
truewhen reconnect support is enabled
-
getReconnectInitialDelayMillis
public long getReconnectInitialDelayMillis()
Returns the initial reconnect delay.- Returns:
- initial delay in milliseconds
-
getReconnectMaxDelayMillis
public long getReconnectMaxDelayMillis()
Returns the maximum reconnect delay.- Returns:
- maximum delay in milliseconds
-
getDiagnosticListener
public PlccomMqttDiagnosticListener getDiagnosticListener()
Returns the optional diagnostic listener.- Returns:
- diagnostic listener, or
nullwhen diagnostic events should be ignored
-
getDiagnosticLevel
public PlccomMqttDiagnosticLevel getDiagnosticLevel()
Returns the minimum diagnostic level delivered to the configured listener.- Returns:
- configured diagnostic level, never
null
-
-