MqttConnection class

Connection to MQTT message broker.

MQTT is a popular light-weight protocol to communicate IoT devices.

Configuration parameters

  • client_id: (optional) name of the client id
  • connection(s):
    • discovery_key: (optional) a key to retrieve the connection from IDiscovery
    • host: host name or IP address
    • port: port number
    • uri: resource URI or connection string with all parameters in it
  • credential(s):
    • store_key: (optional) a key to retrieve the credentials from ICredentialStore
    • username: user name
    • password: user password
  • options:
    • retry_connect: (optional) turns on/off automated reconnect when connection is log (default: true)
    • connect_timeout: (optional) number of milliseconds to wait for connection (default: 30000)
    • reconnect_timeout: (optional) number of milliseconds to wait on each reconnection attempt (default: 1000)
    • keepalive_timeout: (optional) number of milliseconds to ping broker while inactive (default: 3000)

References

  • :logger::*:1.0 (optional) ILogger components to pass log messages
  • :counters::*:1.0 (optional) ICounters components to pass collected measurements
  • :discovery::*:1.0 (optional) IDiscovery services to resolve connections
  • :credential-store::*:1.0 (optional) Credential stores to resolve credentials

See MessageQueue See MessagingCapabilities

Constructors

MqttConnection()

Properties

clientId_ String
getter/setter pair
connection_ ↔ MqttServerClient?
The NATS connection pool object.
getter/setter pair
connectionResolver_ MqttConnectionResolver
The connection resolver.
getter/setter pair
connectTimeout_ int
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
keepAliveTimeout_ int
getter/setter pair
logger_ ↔ CompositeLogger
The logger.
getter/setter pair
options_ ↔ ConfigParams
The configuration options.
getter/setter pair
reconnectTimeout_ int
getter/setter pair
retryConnect_ bool
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subscriptions_ List<MqttSubscription>
Topic subscriptions
getter/setter pair

Methods

checkOpen() → void
Checks if connection is open
close(String? correlationId) Future
Closes component and frees used resources.
configure(ConfigParams config) → void
Configures component by passing configuration parameters.
createQueue(String name) Future<void>
Creates a message queue. If connection doesn't support this function it exists without error.
deleteQueue(String name) Future<void>
Deletes a message queue. If connection doesn't support this function it exists without error.
getConnection() → MqttServerClient?
isOpen() bool
Checks if the component is opened.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open(String? correlationId) Future
Opens the component.
publish(String topic, String data, Map<String, dynamic> options) Future
Publish a message to a specified topic
readQueueNames() Future<List<String>>
Reads a list of registered queue names. If connection doesn't support this function returnes an empty list.
setReferences(IReferences references) → void
Sets references to dependent components.
subscribe(String topic, Map<String, dynamic> options, IMqttMessageListener listener) Future
toString() String
A string representation of this object.
inherited
unsubscribe(String topic, IMqttMessageListener listener) Future

Operators

operator ==(Object other) bool
The equality operator.
inherited