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
This class extends
AwsIotConnection to 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
ConstructorsConstructorDescriptionAwsIotMqttConnection(AbstractAwsIotClient client, SocketFactory socketFactory, String serverUri) -
Method Summary
Modifier and TypeMethodDescriptionvoidcloseConnection(AwsIotMessageCallback callback) Abstract method which is called to terminate an underneath connection.org.eclipse.paho.client.mqttv3.MqttAsyncClientvoidopenConnection(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 Details
-
AwsIotMqttConnection
public AwsIotMqttConnection(AbstractAwsIotClient client, SocketFactory socketFactory, String serverUri) throws AWSIotException - Throws:
AWSIotException
-
-
Method Details
-
openConnection
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
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
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
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
-
getServerUris
-
getSocketFactory
-
getMqttClient
public org.eclipse.paho.client.mqttv3.MqttAsyncClient getMqttClient() -
getMessageListener
-
getClientListener
-
setMqttClient
public void setMqttClient(org.eclipse.paho.client.mqttv3.MqttAsyncClient mqttClient) -
setMessageListener
-
setClientListener
-