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
usernameandpassword, 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.StringgetAddress()Gets the address of the MQTT broker to connect to.java.lang.StringgetClientIdPrefix()Gets the ClientId prefix to be used for shared connections.java.lang.IntegergetConnectionTimeout()Gets the connection timeout expressed in seconds.java.lang.IntegergetKeepAlive()Gets the keep alive interval expressed in seconds.java.lang.StringgetPassword()Gets thepasswordfor authenticating with the MQTT broker.SecurityParamsgetSecurityParams()Gets theSecureParamsinstance to be used for supporting the setting up of encrypted connections to the MQTT broker.java.lang.StringgetUsername()Gets theusernamefor authenticating with the MQTT broker.MqttMessagegetWillMessage()Gets theWill Messageto 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
mqttsandssltriggers 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
nullstring), 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
nullreturn value, a default value of5seconds will be used.- Returns:
- the connection timeout expressed in seconds, or
nullif the default value is accepted
-
getKeepAlive
java.lang.Integer getKeepAlive()Gets the keep alive interval expressed in seconds.In case of a
nullreturn value, a default value of30seconds will be used.- Returns:
- the keep alive interval expressed in seconds, or
nullif the default value is accepted
-
getUsername
java.lang.String getUsername()Gets theusernamefor authenticating with the MQTT broker.If the MQTT broker does not require authentication, this method should return a
nullvalue. Empty or blank values will be provided as is in theCONNECTControl Packet built to connect to the broker.Note that the
usernamewhich may be provided by the client will take precedence over the one returned by this method.- Returns:
- the
username, ornullif no credential is provided - See Also:
MqttConnectOptions.getUsername()
-
getPassword
java.lang.String getPassword()Gets thepasswordfor authenticating with the MQTT broker.As for
getUsername(), this method should returnsnullvalue in the case of unauthenticated access. Empty or blank values will be provided as is in theCONNECTControl Packet built to connect to the broker.Note that the
passwordwhich may be provided by the client will take precedence over the one returned by this method.- Returns:
- the
password, ornullif no credential is provided - See Also:
MqttConnectOptions.getPassword()
-
getWillMessage
MqttMessage getWillMessage()Gets theWill Messageto be stored by the MQTT broker.Note that the
Will Messagewhich may be provided by the client will take precedence over the one returned by this method.- Returns:
- the
Will Messageto be stored by the MQTT broker if any, ornull - See Also:
MqttConnectOptions.getWillMessage()
-
getSecurityParams
SecurityParams getSecurityParams()Gets theSecureParamsinstance 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
nullis 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
SecureParamsinstance, ornull
-