Interface MqttBrokerConfig
public interface MqttBrokerConfig
The Hook is expected to supply an instance of MqttBrokerConfig
(through an invocation
of MQTTCoolHook.resolveAlias(String)
) if no static entries have been provided in the
mqtt_master_connector_conf.xml
file for a given connection alias.
The configuration is made up of:
- Mandatory address of the MQTT broker.
- Optional connection timeout and keep alive interval values.
- Optional ClientId prefix.
- Optional
username
andpassword
, if the MQTT broker requires an authenticated access. - Optional
Will Message
. - Optional set of parameters for encrypted connections.
- See Also:
MQTTCoolHook.resolveAlias(String)
-
Method Summary
Modifier and Type Method Description java.lang.String
getAddress()
Gets the address of the MQTT broker to connect to.java.lang.String
getClientIdPrefix()
Gets the ClientId prefix to be used for shared connections.java.lang.Integer
getConnectionTimeout()
Gets the connection timeout expressed in seconds.java.lang.Integer
getKeepAlive()
Gets the keep alive interval expressed in seconds.java.lang.String
getPassword()
Gets thepassword
for authenticating with the MQTT broker.SecurityParams
getSecurityParams()
Gets theSecureParams
instance to be used for supporting the setting up of encrypted connections to the MQTT broker.java.lang.String
getUsername()
Gets theusername
for authenticating with the MQTT broker.MqttMessage
getWillMessage()
Gets theWill Message
to be stored by the MQTT broker.
-
Method Details
-
getAddress
java.lang.String getAddress()Gets the address of the MQTT broker to connect to.The address must be specified in one of the following URI forms:
tcp://<host>:<port>
mqtt://<host>:<port>
mqtts://<host>:<port>
ssl://<host>:<port>
Note that use of
mqtts
andssl
triggers encrypted communication with the MQTT broker, therefore further parameters (provided through an instance ofSecurityParams
) might be required in order to properly support the setting up of secure channels.- Returns:
- the address of the MQTT broker
- See Also:
getSecurityParams()
-
getClientIdPrefix
java.lang.String getClientIdPrefix()Gets the ClientId prefix to be used for shared connections.If the clients want to share a single connection, MQTT.Cool concatenates the ClientId prefix with a randomly generated suffix in order to make a unique ClientId for opening the physical connection to the MQTT broker. Uniqueness of the ClientId is mandatory as multiple shared connections may exist for the same MQTT broker.
In case of blank return value (that is, an empty, whitespace or
null
string), the default ClientId prefix"MQTT_Cool"
will be used.- Returns:
- the ClientId prefix, or a blank value (as defined above) if the default ClientId prefix is accepted
-
getConnectionTimeout
java.lang.Integer getConnectionTimeout()Gets the connection timeout expressed in seconds.In case of a
null
return value, a default value of5
seconds will be used.- Returns:
- the connection timeout expressed in seconds, or
null
if the default value is accepted
-
getKeepAlive
java.lang.Integer getKeepAlive()Gets the keep alive interval expressed in seconds.In case of a
null
return value, a default value of30
seconds will be used.- Returns:
- the keep alive interval expressed in seconds, or
null
if the default value is accepted
-
getUsername
java.lang.String getUsername()Gets theusername
for authenticating with the MQTT broker.If the MQTT broker does not require authentication, this method should return a
null
value. Empty or blank values will be provided as is in theCONNECT
Control Packet built to connect to the broker.Note that the
username
which may be provided by the client will take precedence over the one returned by this method.- Returns:
- the
username
, ornull
if no credential is provided - See Also:
MqttConnectOptions.getUsername()
-
getPassword
java.lang.String getPassword()Gets thepassword
for authenticating with the MQTT broker.As for
getUsername()
, this method should returnsnull
value in the case of unauthenticated access. Empty or blank values will be provided as is in theCONNECT
Control Packet built to connect to the broker.Note that the
password
which may be provided by the client will take precedence over the one returned by this method.- Returns:
- the
password
, ornull
if no credential is provided - See Also:
MqttConnectOptions.getPassword()
-
getWillMessage
MqttMessage getWillMessage()Gets theWill Message
to be stored by the MQTT broker.Note that the
Will Message
which may be provided by the client will take precedence over the one returned by this method.- Returns:
- the
Will Message
to be stored by the MQTT broker if any, ornull
- See Also:
MqttConnectOptions.getWillMessage()
-
getSecurityParams
SecurityParams getSecurityParams()Gets theSecureParams
instance to be used for supporting the setting up of encrypted connections to the MQTT broker.Note that this method will be invoked only in the case the address returned by
getAddress()
specifies a secure schema.Furthermore, if
null
is returned, the MQTT.Cool server will try to establish a secure channel using the following default settings:- TLSv1.2 as security protocol.
- Default truststore and keystore, determined according to the JSSE Reference Guide.
- Returns:
- a
SecureParams
instance, ornull
-