Class Mqttv5ClientManager
java.lang.Object
org.springframework.integration.mqtt.core.AbstractMqttClientManager<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
org.springframework.integration.mqtt.core.Mqttv5ClientManager
- All Implemented Interfaces:
org.eclipse.paho.mqttv5.client.MqttCallback
,Aware
,BeanNameAware
,ApplicationEventPublisherAware
,Lifecycle
,Phased
,SmartLifecycle
,ClientManager<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,
,org.eclipse.paho.mqttv5.client.MqttConnectionOptions> MqttComponent<org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
public class Mqttv5ClientManager
extends AbstractMqttClientManager<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
implements org.eclipse.paho.mqttv5.client.MqttCallback
A client manager implementation for MQTT v5 protocol. Requires a client ID and server URI.
If needed, the connection options may be overridden and passed as a
MqttConnectionOptions
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
ConstructorDescriptionMqttv5ClientManager
(String url, String clientId) Mqttv5ClientManager
(org.eclipse.paho.mqttv5.client.MqttConnectionOptions connectionOptions, String clientId) -
Method Summary
Modifier and TypeMethodDescriptionvoid
authPacketArrived
(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) void
connectComplete
(boolean reconnect, String serverURI) void
deliveryComplete
(org.eclipse.paho.mqttv5.client.IMqttToken token) void
disconnected
(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse) org.eclipse.paho.mqttv5.client.MqttConnectionOptions
Return information about the connection.boolean
Return the managed clients isConnected.void
messageArrived
(String topic, org.eclipse.paho.mqttv5.common.MqttMessage message) void
mqttErrorOccurred
(org.eclipse.paho.mqttv5.common.MqttException exception) void
setPersistence
(org.eclipse.paho.mqttv5.client.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
-
Mqttv5ClientManager
-
Mqttv5ClientManager
public Mqttv5ClientManager(org.eclipse.paho.mqttv5.client.MqttConnectionOptions connectionOptions, String clientId)
-
-
Method Details
-
setPersistence
public void setPersistence(org.eclipse.paho.mqttv5.client.MqttClientPersistence persistence) Set theMqttClientPersistence
for a client.- Parameters:
persistence
- persistence implementation to use for te client
-
getConnectionInfo
public org.eclipse.paho.mqttv5.client.MqttConnectionOptions getConnectionInfo()Description copied from interface:MqttComponent
Return information about the connection.- Specified by:
getConnectionInfo
in interfaceMqttComponent<org.eclipse.paho.mqttv5.client.MqttConnectionOptions>
- Returns:
- the information.
-
start
public void start() -
stop
public void stop() -
messageArrived
- Specified by:
messageArrived
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
deliveryComplete
public void deliveryComplete(org.eclipse.paho.mqttv5.client.IMqttToken token) - Specified by:
deliveryComplete
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
connectComplete
- Specified by:
connectComplete
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
authPacketArrived
public void authPacketArrived(int reasonCode, org.eclipse.paho.mqttv5.common.packet.MqttProperties properties) - Specified by:
authPacketArrived
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
disconnected
public void disconnected(org.eclipse.paho.mqttv5.client.MqttDisconnectResponse disconnectResponse) - Specified by:
disconnected
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
mqttErrorOccurred
public void mqttErrorOccurred(org.eclipse.paho.mqttv5.common.MqttException exception) - Specified by:
mqttErrorOccurred
in interfaceorg.eclipse.paho.mqttv5.client.MqttCallback
-
isConnected
public boolean isConnected()Description copied from interface:ClientManager
Return the managed clients isConnected.- Specified by:
isConnected
in interfaceClientManager<org.eclipse.paho.mqttv5.client.IMqttAsyncClient,
org.eclipse.paho.mqttv5.client.MqttConnectionOptions> - Returns:
- the managed clients isConnected.
-