Class Mqttv3ClientManager
java.lang.Object
org.springframework.integration.mqtt.core.AbstractMqttClientManager<org.eclipse.paho.client.mqttv3.IMqttAsyncClient,org.eclipse.paho.client.mqttv3.MqttConnectOptions>
org.springframework.integration.mqtt.core.Mqttv3ClientManager
- All Implemented Interfaces:
org.eclipse.paho.client.mqttv3.MqttCallback
,org.eclipse.paho.client.mqttv3.MqttCallbackExtended
,Aware
,BeanNameAware
,ApplicationEventPublisherAware
,Lifecycle
,Phased
,SmartLifecycle
,ClientManager<org.eclipse.paho.client.mqttv3.IMqttAsyncClient,
,org.eclipse.paho.client.mqttv3.MqttConnectOptions> MqttComponent<org.eclipse.paho.client.mqttv3.MqttConnectOptions>
public class Mqttv3ClientManager
extends AbstractMqttClientManager<org.eclipse.paho.client.mqttv3.IMqttAsyncClient,org.eclipse.paho.client.mqttv3.MqttConnectOptions>
implements org.eclipse.paho.client.mqttv3.MqttCallbackExtended
A client manager implementation for MQTT v3 protocol. Requires a client ID and server URI.
If needed, the connection options may be overridden and passed as a
MqttConnectOptions
dependency.
By default, automatic reconnect is used. If it is required to be turned off, one should listen for
MqttConnectionFailedEvent
and reconnect the MQTT client manually.- Since:
- 6.0
- Author:
- Artem Vozhdayenko, Artem Bilan, Christian Tzolov, Jiri Soucek
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.mqtt.core.ClientManager
ClientManager.ConnectCallback
-
Field Summary
Fields inherited from class org.springframework.integration.mqtt.core.AbstractMqttClientManager
lock, logger
Fields inherited from interface org.springframework.integration.mqtt.core.ClientManager
DEFAULT_COMPLETION_TIMEOUT, DISCONNECT_COMPLETION_TIMEOUT
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionMqttv3ClientManager
(String url, String clientId) Mqttv3ClientManager
(org.eclipse.paho.client.mqttv3.MqttConnectOptions connectionOptions, String clientId) -
Method Summary
Modifier and TypeMethodDescriptionvoid
connectComplete
(boolean reconnect, String serverURI) void
connectionLost
(Throwable cause) void
deliveryComplete
(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token) org.eclipse.paho.client.mqttv3.MqttConnectOptions
Return information about the connection.boolean
Return the managed clients isConnected.void
messageArrived
(String topic, org.eclipse.paho.client.mqttv3.MqttMessage message) void
setPersistence
(org.eclipse.paho.client.mqttv3.MqttClientPersistence persistence) Set theMqttClientPersistence
for a client.void
start()
void
stop()
Methods inherited from class org.springframework.integration.mqtt.core.AbstractMqttClientManager
addCallback, getApplicationEventPublisher, getBeanName, getCallbacks, getClient, getClientId, getCompletionTimeout, getDisconnectCompletionTimeout, getPhase, getUrl, isManualAcks, isRunning, removeCallback, setApplicationEventPublisher, setBeanName, setClient, setCompletionTimeout, setDisconnectCompletionTimeout, setManualAcks, setPhase, setUrl
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.SmartLifecycle
isAutoStartup, stop
-
Constructor Details
-
Mqttv3ClientManager
-
Mqttv3ClientManager
public Mqttv3ClientManager(org.eclipse.paho.client.mqttv3.MqttConnectOptions connectionOptions, String clientId)
-
-
Method Details
-
setPersistence
public void setPersistence(org.eclipse.paho.client.mqttv3.MqttClientPersistence persistence) Set theMqttClientPersistence
for a client.- Parameters:
persistence
- persistence implementation to use for te client
-
getConnectionInfo
public org.eclipse.paho.client.mqttv3.MqttConnectOptions getConnectionInfo()Description copied from interface:MqttComponent
Return information about the connection.- Specified by:
getConnectionInfo
in interfaceMqttComponent<org.eclipse.paho.client.mqttv3.MqttConnectOptions>
- Returns:
- the information.
-
start
public void start() -
stop
public void stop() -
connectionLost
- Specified by:
connectionLost
in interfaceorg.eclipse.paho.client.mqttv3.MqttCallback
-
connectComplete
- Specified by:
connectComplete
in interfaceorg.eclipse.paho.client.mqttv3.MqttCallbackExtended
-
messageArrived
- Specified by:
messageArrived
in interfaceorg.eclipse.paho.client.mqttv3.MqttCallback
-
deliveryComplete
public void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token) - Specified by:
deliveryComplete
in interfaceorg.eclipse.paho.client.mqttv3.MqttCallback
-
isConnected
public boolean isConnected()Description copied from interface:ClientManager
Return the managed clients isConnected.- Specified by:
isConnected
in interfaceClientManager<org.eclipse.paho.client.mqttv3.IMqttAsyncClient,
org.eclipse.paho.client.mqttv3.MqttConnectOptions> - Returns:
- the managed clients isConnected.
-