in sdk/src/main/java/software/amazon/awssdk/iot/iotshadow/IotShadowClient.java [1133:1163]
public CompletableFuture<Integer> SubscribeToUpdateNamedShadowAccepted(
UpdateNamedShadowSubscriptionRequest request,
QualityOfService qos,
Consumer<UpdateShadowResponse> handler,
Consumer<Exception> exceptionHandler) {
String topic = "$aws/things/{thingName}/shadow/name/{shadowName}/update/accepted";
if (request.thingName == null) {
CompletableFuture<Integer> result = new CompletableFuture<Integer>();
result.completeExceptionally(new MqttException("UpdateNamedShadowSubscriptionRequest 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("UpdateNamedShadowSubscriptionRequest 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);
UpdateShadowResponse response = gson.fromJson(payload, UpdateShadowResponse.class);
handler.accept(response);
} catch (Exception e) {
if (exceptionHandler != null) {
exceptionHandler.accept(e);
}
}
};
return connection.subscribe(topic, qos, messageHandler);
}