Class AwsIotMqttConnection
- java.lang.Object
-
- com.amazonaws.services.iot.client.core.AwsIotConnection
-
- com.amazonaws.services.iot.client.mqtt.AwsIotMqttConnection
-
- All Implemented Interfaces:
AwsIotConnectionCallback
- Direct Known Subclasses:
AwsIotTlsConnection,AwsIotWebsocketConnection
public class AwsIotMqttConnection extends AwsIotConnection
This class extendsAwsIotConnectionto provide the basic MQTT pub/sub functionalities using the Paho MQTT library.
-
-
Field Summary
-
Fields inherited from class com.amazonaws.services.iot.client.core.AwsIotConnection
client, connectionStatus
-
-
Constructor Summary
Constructors Constructor Description AwsIotMqttConnection(AbstractAwsIotClient client, SocketFactory socketFactory, String serverUri)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseConnection(AwsIotMessageCallback callback)Abstract method which is called to terminate an underneath connection.AwsIotMqttClientListenergetClientListener()AwsIotMqttMessageListenergetMessageListener()org.eclipse.paho.client.mqttv3.MqttAsyncClientgetMqttClient()Set<String>getServerUris()SocketFactorygetSocketFactory()voidopenConnection(AwsIotMessageCallback callback)Abstract method which is called to establish an underneath connection.voidpublishMessage(AWSIotMessage message)Abstract method which is called to publish a message.voidsetClientListener(AwsIotMqttClientListener clientListener)voidsetMessageListener(AwsIotMqttMessageListener messageListener)voidsetMqttClient(org.eclipse.paho.client.mqttv3.MqttAsyncClient mqttClient)voidsubscribeTopic(AWSIotMessage message)Abstract method which is called to subscribe to a topic.voidunsubscribeTopic(AWSIotMessage message)Abstract method which is called to unsubscribe to a topic.-
Methods inherited from class com.amazonaws.services.iot.client.core.AwsIotConnection
connect, disconnect, getClient, getConnectCallback, getConnectionStatus, getPublishQueue, getRetryTask, getRetryTimes, getSubscribeQueue, getUnsubscribeQueue, isUserDisconnect, onConnectionClosed, onConnectionFailure, onConnectionSuccess, publish, setConnectionStatus, subscribe, unsubscribe, updateCredentials
-
-
-
-
Constructor Detail
-
AwsIotMqttConnection
public AwsIotMqttConnection(AbstractAwsIotClient client, SocketFactory socketFactory, String serverUri) throws AWSIotException
- Throws:
AWSIotException
-
-
Method Detail
-
openConnection
public void openConnection(AwsIotMessageCallback callback) throws AWSIotException
Description copied from class:AwsIotConnectionAbstract method which is called to establish an underneath connection.- Specified by:
openConnectionin classAwsIotConnection- Parameters:
callback- connection callback functions- Throws:
AWSIotException- this exception is thrown when the request is failed to be sent
-
closeConnection
public void closeConnection(AwsIotMessageCallback callback) throws AWSIotException
Description copied from class:AwsIotConnectionAbstract method which is called to terminate an underneath connection.- Specified by:
closeConnectionin classAwsIotConnection- Parameters:
callback- connection callback functions- Throws:
AWSIotException- this exception is thrown when the request is failed to be sent
-
publishMessage
public void publishMessage(AWSIotMessage message) throws AWSIotException, AwsIotRetryableException
Description copied from class:AwsIotConnectionAbstract method which is called to publish a message.- Specified by:
publishMessagein classAwsIotConnection- Parameters:
message- the message to be published- Throws:
AWSIotException- this exception is thrown when there's an unrecoverable error happened while processing the requestAwsIotRetryableException- this exception is thrown when the request is failed to be sent, which will be queued and retried
-
subscribeTopic
public void subscribeTopic(AWSIotMessage message) throws AWSIotException, AwsIotRetryableException
Description copied from class:AwsIotConnectionAbstract method which is called to subscribe to a topic.- Specified by:
subscribeTopicin classAwsIotConnection- Parameters:
message- the topic to be subscribed to- Throws:
AWSIotException- this exception is thrown when there's an unrecoverable error happened while processing the requestAwsIotRetryableException- this exception is thrown when the request is failed to be sent, which will be queued and retried
-
unsubscribeTopic
public void unsubscribeTopic(AWSIotMessage message) throws AWSIotException, AwsIotRetryableException
Description copied from class:AwsIotConnectionAbstract method which is called to unsubscribe to a topic.- Specified by:
unsubscribeTopicin classAwsIotConnection- Parameters:
message- the topic to be unsubscribed to- Throws:
AWSIotException- this exception is thrown when there's an unrecoverable error happened while processing the requestAwsIotRetryableException- this exception is thrown when the request is failed to be sent, which will be queued and retried
-
getSocketFactory
public SocketFactory getSocketFactory()
-
getMqttClient
public org.eclipse.paho.client.mqttv3.MqttAsyncClient getMqttClient()
-
getMessageListener
public AwsIotMqttMessageListener getMessageListener()
-
getClientListener
public AwsIotMqttClientListener getClientListener()
-
setMqttClient
public void setMqttClient(org.eclipse.paho.client.mqttv3.MqttAsyncClient mqttClient)
-
setMessageListener
public void setMessageListener(AwsIotMqttMessageListener messageListener)
-
setClientListener
public void setClientListener(AwsIotMqttClientListener clientListener)
-
-