in sdk/src/main/java/software/amazon/awssdk/iot/iotshadow/IotShadowClient.java [653:683]
public CompletableFuture<Integer> SubscribeToGetNamedShadowRejected(
GetNamedShadowSubscriptionRequest request,
QualityOfService qos,
Consumer<ErrorResponse> handler,
Consumer<Exception> exceptionHandler) {
String topic = "$aws/things/{thingName}/shadow/name/{shadowName}/get/rejected";
if (request.thingName == null) {
CompletableFuture<Integer> result = new CompletableFuture<Integer>();
result.completeExceptionally(new MqttException("GetNamedShadowSubscriptionRequest must have a non-null thingName"));
return result;
}
topic = topic.replace("{thingName}", request.thingName);
if (request.shadowName == null) {
CompletableFuture<Integer> result = new CompletableFuture<Integer>();
result.completeExceptionally(new MqttException("GetNamedShadowSubscriptionRequest must have a non-null shadowName"));
return result;
}
topic = topic.replace("{shadowName}", request.shadowName);
Consumer<MqttMessage> messageHandler = (message) -> {
try {
String payload = new String(message.getPayload(), StandardCharsets.UTF_8);
ErrorResponse response = gson.fromJson(payload, ErrorResponse.class);
handler.accept(response);
} catch (Exception e) {
if (exceptionHandler != null) {
exceptionHandler.accept(e);
}
}
};
return connection.subscribe(topic, qos, messageHandler);
}