【发布时间】:2021-07-30 21:18:48
【问题描述】:
在我的应用程序的 Azure Cosmo DocumentDB 中,出现以下错误
2018-03-27 14:42:057 错误 c.h.m.s.CosmosDBFruiteService - 不能 将 Fruites 添加到客户参考中: 11416e34-3620-45a4-b3be-b845bbf41762
消息:{“错误”:[“具有指定 ID 或名称的资源已存在。”]} ActivityId:1b70b944-d581-4640-8785- 819400433bb4, 请求 URI: /apps/8d13f597-c7e4-4d60-8713-8a0e9abaa9ac/services/ce0d287f-0125-482b-b32c-22108b5b0ed3/partitions/42c80a49-8042-4032-8cfd-9937ecea8dcc/replicas/1316682740046 RequestStats:,SDK:Microsoft.Azure.Documents.Common/1.21.0.0, 状态码:冲突 2018-03-27 14:42:058 错误 c.h.m.a.e.GlobalExceptionHandler - 异常:类 org.apache.catalina.connector.ClientAbortException 消息: java.io.IOException:现有连接被强制关闭 远程主机 2018-03-27 14:42:058 警告 o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - 调用失败 @ExceptionHandler 方法:公共 java.util.Map com.hm.myfeed.api.exception.GlobalExceptionHandler.handleException(java.lang.Exception,org.springframework.web.context.request.WebRequest,javax.servlet.http.HttpServletRequest) org.apache.catalina.connector.ClientAbortException: java.io.IOException:现有连接被强制关闭 远程主机在 org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356) 在 org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:815) 在 org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:720) 在 org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391) 在 org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:369) 在 org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) 在 org.springframework.security.web.util.OnCommittedResponseWrapper$SaveContextServletOutputStream.write(OnCommittedResponseWrapper.java:639)
我有点不明白这一点。异常发生在首先检查集合是否存在(确实存在)然后是否不创建它的代码中。显然创建会失败,集合存在!!
创建函数
try {
fruitesDocument = documentClient.createDocument(getCollectionLink(), fruitesDocument , null, false).getResource();
} catch (DocumentClientException e) {
LOG.error("Could not add fruits for Customer Reference: " + fruitesModel.getId() + " " + e.getMessage());
}
更新功能:
try {
fruitesDocument = documentClient.replaceDocument(fruitesDocument , null).getResource();
} catch (DocumentClientException e) {
LOG.error("Error while updating fruites: " + e.getMessage());
}
创建文档时遇到问题。
【问题讨论】:
标签: azure azure-cosmosdb document-database azure-java-sdk