See: Description
Interface | Description |
---|---|
IMqttActionListener |
Implementors of this interface will be notified when an asynchronous action completes.
|
IMqttAsyncClient |
Enables an application to communicate with an MQTT server using non-blocking methods.
|
IMqttClient |
Enables an application to communicate with an MQTT server using blocking methods.
|
IMqttDeliveryToken |
Provides a mechanism for tracking the delivery of a message.
|
IMqttMessageListener |
Implementers of this interface will be notified when a message arrives.
|
IMqttToken |
Provides a mechanism for tracking the completion of an asynchronous task.
|
MqttCallback |
Enables an application to be notified when asynchronous
events related to the client occur.
|
MqttCallbackExtended |
Extension of
MqttCallback to allow new callbacks
without breaking the API for existing applications. |
MqttClientPersistence |
Represents a persistent data store, used to store outbound and inbound messages while they
are in flight, enabling delivery to the QoS specified.
|
MqttPersistable |
Represents an object used to pass data to be persisted across the
MqttClientPersistence
interface. |
MqttPingSender |
Represents an object used to send ping packet to MQTT broker
every keep alive interval.
|
Class | Description |
---|---|
BufferedMessage |
A BufferedMessage contains an MqttWire Message and token
it allows both message and token to be buffered when the client
is in resting state
|
DisconnectedBufferOptions |
Holds the set of options that govern the behaviour
of Offline (or Disconnected) buffering of messages
|
MqttAsyncClient |
Lightweight client for talking to an MQTT server using non-blocking methods
that allow an operation to run in the background.
|
MqttClient |
Lightweight client for talking to an MQTT server using methods that block
until an operation completes.
|
MqttConnectOptions |
Holds the set of options that control how the client connects to a server.
|
MqttDeliveryToken |
Provides a mechanism to track the delivery progress of a message.
|
MqttMessage |
An MQTT message holds the application payload and options
specifying how the message is to be delivered
The message includes a "payload" (the body of the message)
represented as a byte[].
|
MqttToken |
Provides a mechanism for tracking the completion of an asynchronous action.
|
MqttTopic |
Represents a topic destination, used for publish/subscribe messaging.
|
TimerPingSender |
Default ping sender implementation
|
Exception | Description |
---|---|
MqttException |
Thrown if an error occurs communicating with the server.
|
MqttPersistenceException |
This exception is thrown by the implementor of the persistence
interface if there is a problem reading or writing persistent data.
|
MqttSecurityException |
Thrown when a client is not authorized to perform an operation, or
if there is a problem with the security configuration.
|
The MQ Telemetry Transport (MQTT) is a lightweight broker-based publish/subscribe messaging protocol designed to be open, simple, lightweight and easy to implement. These characteristics make it ideal for use in constrained environments, for example, but not limited to:
Features of the protocol include:
The basic means of operating the client is:
MqttClient
or
MqttAsyncClient
, providing
the address of an MQTT server and a unique client identifier.connect
to the serverpublish messages
to the server
specifying a topic
as the destination on the serversubscribe
to one more topics
. The server will send any messages
it receives on those topics to the client. The client will be informed when a message
arrives via a callback
disconnect
from the server.The programming model and concepts like the protocol are small and easy to use. Key concepts to use when creating MQTT application include:
MqttDefaultFilePersistence
is used.
cleansession
option has a big impact on the operation of the client. If set to false:
MqttAsyncClient
which provides a non-blocking interface where
methods return before the requested operation has completed. The completion of the operation
can be monitored by in several ways:
waitForCompletion
call on the token returned from the operation. This will block
until the operation completes.
IMqttActionListener
to the operation. The listener will then be called back when the operation completes.
MqttCallback
on the client. It
will be notified when a message arrives, a message have been delivered to the server and when the
connection to the server is lost.
MqttClient
where methods block until
the operation has completed.
messageArrived
.
connectionLost
.
deliveryComplete
.
MqttCallback
on the client
org.eclipse.paho.sample.mqttv3app.Sample
uses the blocking client interface
org.eclipse.paho.sample.mqttv3app.SampleAsyncCallBack
uses the asynchronous client with
callbacks which are notified when an operation completes
org.eclipse.paho.sample.mqttv3app.SampleAsyncWait
uses the asynchronous client and
shows how to use the token returned from each operation to block until the operation completes.
MqttConnectOptions
can be used to override the
default connection options. This includes: