Class AwsIotCompletion
java.lang.Object
com.amazonaws.services.iot.client.AWSIotMessage
com.amazonaws.services.iot.client.core.AwsIotCompletion
- All Implemented Interfaces:
AwsIotMessageCallback
- Direct Known Subclasses:
AwsIotDeviceCommand
This is a helper class that can be used to manage the request execution and
return either synchronously or asynchronously the result, e.g. success,
failure, or timeout. It's used by most of the APIs to implement blocking and
non-blocking calls with timeout support.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanIndicates whether the request has completed with failure.protected booleanIndicates whether the request has completed successfully.protected booleanIndicates whether the request has timed out.protected final booleanwhether the request is asynchronous or not.protected final AWSIotMessageThe request containing the callback functions.protected final longThe timeout associated with the request.protected Future<?>The future object of the timeout task.Fields inherited from class com.amazonaws.services.iot.client.AWSIotMessage
errorCode, errorMessage, payload, qos, topic -
Constructor Summary
ConstructorsConstructorDescriptionAwsIotCompletion(long timeout, boolean isAsync) Instantiates a new completion object either synchronous or asynchronous request based on theisAsyncargument.AwsIotCompletion(AWSIotMessage req, long timeout, boolean isAsync) Instantiates a new completion object either synchronous or asynchronous request based on theisAsyncargument.AwsIotCompletion(String topic, AWSIotQos qos, byte[] payload, long timeout) Instantiates a new completion object with a synchronous request.AwsIotCompletion(String topic, AWSIotQos qos, long timeout) Instantiates a new completion object with a synchronous request.AwsIotCompletion(String topic, AWSIotQos qos, String payload, long timeout) Instantiates a new completion object with a synchronous request. -
Method Summary
Modifier and TypeMethodDescriptionvoidget(AbstractAwsIotClient client) The user of the completion object is expected to call this function to either block until the request is completed or timed out in the case of synchronous calls, or to schedule a timeout handler in the case of asynchronous calls.voidCallback function to be invoked a non-block API has completed unsuccessfully.voidCallback function to be invoked a non-block API has completed successfully.voidCallback function to be invoked a non-block API has timed out.Methods inherited from class com.amazonaws.services.iot.client.AWSIotMessage
getErrorCode, getErrorMessage, getPayload, getQos, getStringPayload, getTopic, setErrorCode, setErrorMessage, setPayload, setQos, setStringPayload, setTopic
-
Field Details
-
request
The request containing the callback functions. -
timeout
protected final long timeoutThe timeout associated with the request. -
isAsync
protected final boolean isAsyncwhether the request is asynchronous or not. -
timeoutTask
The future object of the timeout task. -
hasSuccess
protected boolean hasSuccessIndicates whether the request has completed successfully. -
hasFailure
protected boolean hasFailureIndicates whether the request has completed with failure. -
hasTimeout
protected boolean hasTimeoutIndicates whether the request has timed out.
-
-
Constructor Details
-
AwsIotCompletion
Instantiates a new completion object with a synchronous request.- Parameters:
topic- the topic of the requestqos- the QoS of the requesttimeout- the timeout in milliseconds for the request. If timeout is 0 or less, the request will never be timed out.
-
AwsIotCompletion
Instantiates a new completion object with a synchronous request.- Parameters:
topic- the topic of the requestqos- the QoS of the requestpayload- the string payload of the requesttimeout- the timeout in milliseconds for the request. If timeout is 0 or less, the request will never be timed out.
-
AwsIotCompletion
Instantiates a new completion object with a synchronous request.- Parameters:
topic- the topic of the requestqos- the QoS of the requestpayload- the byte array payload of the requesttimeout- the timeout in milliseconds for the request. If timeout is 0 or less, the request will never be timed out.
-
AwsIotCompletion
public AwsIotCompletion(long timeout, boolean isAsync) Instantiates a new completion object either synchronous or asynchronous request based on theisAsyncargument.- Parameters:
timeout- the timeout in milliseconds for the request. If timeout is 0 or less, the request will never be timed out.isAsync- whether or not the request is asynchronous
-
AwsIotCompletion
Instantiates a new completion object either synchronous or asynchronous request based on theisAsyncargument. Callback functions are provided through thereqargument.- Parameters:
req- the request containing request topic, QoS, payload, and callback functions for asynchronous requests.timeout- the timeout in milliseconds for the request. If timeout is 0 or less, the request will never be timed out.isAsync- whether or not the request is asynchronous
-
-
Method Details
-
get
The user of the completion object is expected to call this function to either block until the request is completed or timed out in the case of synchronous calls, or to schedule a timeout handler in the case of asynchronous calls.- Parameters:
client- the client object that provides the execution thread pool for the timeout handler.- Throws:
AWSIotException- For synchronous calls, this exception may be thrown if the request has failed.AWSIotTimeoutException- For synchronous calls, this exception may be thrown if the request has timed out.
-
onSuccess
public void onSuccess()Description copied from class:AWSIotMessageCallback function to be invoked a non-block API has completed successfully.- Specified by:
onSuccessin interfaceAwsIotMessageCallback- Overrides:
onSuccessin classAWSIotMessage
-
onFailure
public void onFailure()Description copied from class:AWSIotMessageCallback function to be invoked a non-block API has completed unsuccessfully.- Specified by:
onFailurein interfaceAwsIotMessageCallback- Overrides:
onFailurein classAWSIotMessage
-
onTimeout
public void onTimeout()Description copied from class:AWSIotMessageCallback function to be invoked a non-block API has timed out.- Specified by:
onTimeoutin interfaceAwsIotMessageCallback- Overrides:
onTimeoutin classAWSIotMessage
-