在过去使用DynamoDBMapper时,我能够在批量放置有关错误消息的项后获得信息。现在使用EnchancedDynamoDBClient进行批处理,我只能获得该项目的键。有什么方法可以得到为什么特定项目的批次不起作用的信息吗?
private void saveToDb(DynamoDbTable<PartImportWarehouse>partStockDataTable, List<PartImportWarehouse> modifiedImportaWrehouse, DynamoDbEnhancedClient dynamoDbEnhancedClient) {
WriteBatch.Builder<PartImportWarehouse> writeBatchBuilder = WriteBatch.builder(PartImportWarehouse.class)
.mappedTableResource(partStockDataTable);
modifiedImportaWrehouse.forEach(writeBatchBuilder::addPutItem);
BatchWriteItemEnhancedRequest batchRequestBuilder = BatchWriteItemEnhancedRequest.builder()
.addWriteBatch(writeBatchBuilder.build())
.build();
BatchWriteResult batchWriteResult = dynamoDbEnhancedClient.batchWriteItem(batchRequestBuilder);
if (!CollectionUtils.isEmpty(batchWriteResult.unprocessedPutItemsForTable(partStockDataTable))) {
log.warn(batchWriteResult.unprocessedPutItemsForTable(partStockDataTable).stream()
.map(i -> "issue with " + i.getKey())
.collect(Collectors.joining(", ")));
}
}
1条答案
按热度按时间g2ieeal71#
如果整个批处理失败,您将仅看到有关批处理失败原因的信息。部分失败并不表示失败的原因,这对于Mapper和Enhanced客户端都是一样的。