Class PlccomMqttClientOptions.Builder
- java.lang.Object
-
- com.plccom.mqtt.client.PlccomMqttClientOptions.Builder
-
- Enclosing class:
- PlccomMqttClientOptions
public static final class PlccomMqttClientOptions.Builder extends Object
Builder forPlccomMqttClientOptions.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlccomMqttClientOptions.BuilderautomaticReconnect(boolean value)Enables or disables bounded automatic reconnect.PlccomMqttClientOptionsbuild()Builds immutable MQTT client options.PlccomMqttClientOptions.BuildercleanStart(boolean value)Sets the MQTT clean-start flag.PlccomMqttClientOptions.BuilderclientId(String value)Sets the MQTT client identifier.PlccomMqttClientOptions.BuilderconnectTimeoutMillis(long value)Sets the socket connect timeout.PlccomMqttClientOptions.BuilderdiagnosticLevel(PlccomMqttDiagnosticLevel value)Sets the minimum diagnostic level delivered to the listener.PlccomMqttClientOptions.BuilderdiagnosticListener(PlccomMqttDiagnosticListener value)Sets the optional diagnostic listener.PlccomMqttClientOptions.BuilderenhancedAuthentication(String method, byte[] initialData, PlccomMqttClientEnhancedAuthenticator authenticator)Configures MQTT 5 enhanced authentication for the CONNECT handshake.PlccomMqttClientOptions.BuilderenhancedAuthentication(String method, PlccomMqttClientEnhancedAuthenticator authenticator)Configures MQTT 5 enhanced authentication without initial CONNECT Authentication Data.PlccomMqttClientOptions.BuilderkeepAliveSeconds(int value)Sets the keep-alive interval.PlccomMqttClientOptions.BuilderlastWill(PlccomMqttLastWill value)Sets the optional MQTT Last Will configuration.PlccomMqttClientOptions.Builderlimits(PlccomMqttLimits value)Sets packet and queue safety limits.PlccomMqttClientOptions.BuilderlocalAddress(InetAddress value)Sets the optional local address for the outgoing MQTT socket.PlccomMqttClientOptions.BuildernoEnhancedAuthentication()Disables MQTT 5 enhanced authentication.PlccomMqttClientOptions.BuilderoperationTimeoutMillis(long value)Sets the timeout for blocking MQTT operations.PlccomMqttClientOptions.Builderpassword(byte[] value)Sets the optional MQTT password from bytes.PlccomMqttClientOptions.Builderpassword(char[] value)Sets the optional MQTT password from characters.PlccomMqttClientOptions.BuilderprotocolVersion(PlccomMqttProtocolVersion value)Sets the requested MQTT protocol version.PlccomMqttClientOptions.BuilderreconnectDelaysMillis(long initialDelayMillis, long maxDelayMillis)Sets the reconnect backoff range.PlccomMqttClientOptions.BuildersessionExpiryIntervalSeconds(Long value)Sets the MQTT 5 session expiry interval.PlccomMqttClientOptions.BuildersocketReadTimeoutMillis(int value)Sets the socket read timeout used while waiting for data from the broker.PlccomMqttClientOptions.BuildertlsOptions(PlccomMqttTlsOptions value)Sets the TLS options for secure endpoints.PlccomMqttClientOptions.BuildertopicAliasMaximum(int value)Sets the MQTT 5 Topic Alias Maximum advertised by this client.PlccomMqttClientOptions.Builderusername(String value)Sets the optional MQTT username.
-
-
-
Method Detail
-
clientId
public PlccomMqttClientOptions.Builder clientId(String value)
Sets the MQTT client identifier.- Parameters:
value- client identifier sent in CONNECT- Returns:
- this builder
- Throws:
NullPointerException- ifvalueisnullduringbuild()IllegalArgumentException- ifvalueis empty duringbuild()
-
protocolVersion
public PlccomMqttClientOptions.Builder protocolVersion(PlccomMqttProtocolVersion value)
Sets the requested MQTT protocol version.- Parameters:
value- requested version orPlccomMqttProtocolVersion.AUTO- Returns:
- this builder
- Throws:
NullPointerException- ifvalueisnull
-
cleanStart
public PlccomMqttClientOptions.Builder cleanStart(boolean value)
Sets the MQTT clean-start flag.- Parameters:
value-trueto start with a clean broker session- Returns:
- this builder
-
sessionExpiryIntervalSeconds
public PlccomMqttClientOptions.Builder sessionExpiryIntervalSeconds(Long value)
Sets the MQTT 5 session expiry interval.- Parameters:
value- session expiry in seconds, ornullto omit the MQTT 5 property- Returns:
- this builder
- Throws:
IllegalArgumentException- ifvalueis outside the MQTT unsigned 32-bit range duringbuild()
-
keepAliveSeconds
public PlccomMqttClientOptions.Builder keepAliveSeconds(int value)
Sets the keep-alive interval.- Parameters:
value- keep-alive interval in seconds;0disables MQTT keep-alive pings- Returns:
- this builder
- Throws:
IllegalArgumentException- ifvalueis outside0..65535duringbuild()
-
lastWill
public PlccomMqttClientOptions.Builder lastWill(PlccomMqttLastWill value)
Sets the optional MQTT Last Will configuration.- Parameters:
value- Last Will configuration, ornullto omit the Will from CONNECT- Returns:
- this builder
-
username
public PlccomMqttClientOptions.Builder username(String value)
Sets the optional MQTT username.- Parameters:
value- username, ornullto omit it- Returns:
- this builder
-
password
public PlccomMqttClientOptions.Builder password(byte[] value)
Sets the optional MQTT password from bytes.- Parameters:
value- password bytes, ornullto omit the password- Returns:
- this builder
-
password
public PlccomMqttClientOptions.Builder password(char[] value)
Sets the optional MQTT password from characters.The password is encoded as UTF-8 bytes for MQTT transmission.
- Parameters:
value- password characters, ornullto omit the password- Returns:
- this builder
-
enhancedAuthentication
public PlccomMqttClientOptions.Builder enhancedAuthentication(String method, byte[] initialData, PlccomMqttClientEnhancedAuthenticator authenticator)
Configures MQTT 5 enhanced authentication for the CONNECT handshake.The method and optional initial data are sent in the CONNECT properties. The authenticator is called synchronously when the broker sends AUTH challenges before CONNACK. Slow implementations can make connect and reconnect attempts slower.
- Parameters:
method- MQTT 5 Authentication Method to send in CONNECTinitialData- MQTT 5 Authentication Data to send in CONNECT, ornullto omit itauthenticator- handler for broker AUTH challenges, ornullwhen no challenge response is needed- Returns:
- this builder
- Throws:
NullPointerException- ifmethodisnullIllegalArgumentException- ifmethodis empty duringbuild()
-
enhancedAuthentication
public PlccomMqttClientOptions.Builder enhancedAuthentication(String method, PlccomMqttClientEnhancedAuthenticator authenticator)
Configures MQTT 5 enhanced authentication without initial CONNECT Authentication Data.- Parameters:
method- MQTT 5 Authentication Method to send in CONNECTauthenticator- handler for broker AUTH challenges, ornullwhen no challenge response is needed- Returns:
- this builder
- Throws:
NullPointerException- ifmethodisnull
-
noEnhancedAuthentication
public PlccomMqttClientOptions.Builder noEnhancedAuthentication()
Disables MQTT 5 enhanced authentication.- Returns:
- this builder
-
topicAliasMaximum
public PlccomMqttClientOptions.Builder topicAliasMaximum(int value)
Sets the MQTT 5 Topic Alias Maximum advertised by this client.Use
0to keep inbound Topic Alias support disabled. Use a positive value when this client is prepared to maintain a per-connection alias table for broker-to-client PUBLISH packets.- Parameters:
value- maximum accepted Topic Alias value, or0to disable inbound Topic Aliases- Returns:
- this builder
- Throws:
IllegalArgumentException- ifvalueis outside0..65535duringbuild()
-
tlsOptions
public PlccomMqttClientOptions.Builder tlsOptions(PlccomMqttTlsOptions value)
Sets the TLS options for secure endpoints.- Parameters:
value- TLS options- Returns:
- this builder
- Throws:
NullPointerException- ifvalueisnull
-
limits
public PlccomMqttClientOptions.Builder limits(PlccomMqttLimits value)
Sets packet and queue safety limits.- Parameters:
value- safety limits- Returns:
- this builder
- Throws:
NullPointerException- ifvalueisnull
-
connectTimeoutMillis
public PlccomMqttClientOptions.Builder connectTimeoutMillis(long value)
Sets the socket connect timeout.- Parameters:
value- timeout in milliseconds- Returns:
- this builder
- Throws:
IllegalArgumentException- ifvalueis not positive duringbuild()
-
operationTimeoutMillis
public PlccomMqttClientOptions.Builder operationTimeoutMillis(long value)
Sets the timeout for blocking MQTT operations.- Parameters:
value- timeout in milliseconds- Returns:
- this builder
- Throws:
IllegalArgumentException- ifvalueis not positive duringbuild()
-
socketReadTimeoutMillis
public PlccomMqttClientOptions.Builder socketReadTimeoutMillis(int value)
Sets the socket read timeout used while waiting for data from the broker.- Parameters:
value- timeout in milliseconds- Returns:
- this builder
- Throws:
IllegalArgumentException- ifvalueis outside100..60000duringbuild()
-
localAddress
public PlccomMqttClientOptions.Builder localAddress(InetAddress value)
Sets the optional local address for the outgoing MQTT socket.When set, the socket is bound to this address before connecting, so MQTT traffic leaves through the network interface that owns the address. The broker host is then resolved only to addresses of the same family (IPv4/IPv6); when the host has no such address, the connect fails with a clear error instead of silently using another interface. The binding applies to plain TCP, TLS, WebSocket and secure WebSocket transports and is re-applied on every automatic reconnect.
- Parameters:
value- local bind address, ornullwhen the operating system selects the outgoing interface (default)- Returns:
- this builder
-
automaticReconnect
public PlccomMqttClientOptions.Builder automaticReconnect(boolean value)
Enables or disables bounded automatic reconnect.- Parameters:
value-trueto retry a failed operation after reconnect- Returns:
- this builder
-
reconnectDelaysMillis
public PlccomMqttClientOptions.Builder reconnectDelaysMillis(long initialDelayMillis, long maxDelayMillis)
Sets the reconnect backoff range.- Parameters:
initialDelayMillis- first reconnect delay in millisecondsmaxDelayMillis- maximum reconnect delay in milliseconds- Returns:
- this builder
- Throws:
IllegalArgumentException- if either value is not positive, or the initial delay is greater than the maximum delay duringbuild()
-
diagnosticListener
public PlccomMqttClientOptions.Builder diagnosticListener(PlccomMqttDiagnosticListener value)
Sets the optional diagnostic listener.The listener receives recoverable background errors, callback failures and other SDK diagnostics that are useful for logging or UI notifications. Direct operation failures are still reported by the normal checked exceptions thrown by client methods.
- Parameters:
value- diagnostic listener, ornullto ignore diagnostic events- Returns:
- this builder
-
diagnosticLevel
public PlccomMqttClientOptions.Builder diagnosticLevel(PlccomMqttDiagnosticLevel value)
Sets the minimum diagnostic level delivered to the listener.Use
PlccomMqttDiagnosticLevel.DEBUGwhile investigating a specific issue,PlccomMqttDiagnosticLevel.WARNINGorPlccomMqttDiagnosticLevel.ERRORfor quieter production logging, andPlccomMqttDiagnosticLevel.OFFwhen diagnostic callbacks should be completely disabled.- Parameters:
value- minimum diagnostic level to deliver- Returns:
- this builder
- Throws:
NullPointerException- ifvalueisnull
-
build
public PlccomMqttClientOptions build()
Builds immutable MQTT client options.- Returns:
- validated client options
- Throws:
NullPointerException- if a required object option isnullIllegalArgumentException- if a configured numeric value is out of range
-
-