05-22-2020 09:32 AM
Hi guys,
first of all thanks for reading my question!
I have a problem with concurrent insertion of documents using nodes api:
/nodes/{nodeId}/children?autoRename=true
It returns 409 when i try inserting 5 documents with the same name concurrently.
Can you please help me avoid 409 error.
Thanks for reading, I would apreciate any idea that leads to solution.
05-23-2020 08:27 AM
I solved the problem by synchronizing insert calls. See code below:
private static Object lockingObjectInsert = new Object();
private Response<NodeRepresentation> insertSynchronized(Document documentEntity,NodeBodyCreate documentBody) throws IOException { synchronized (lockingObjectInsert) { Response<NodeRepresentation> responseCreate = getNodesAPI().createNodeCall(getFolderId(documentEntity), documentBody,true,null,null).execute(); return responseCreate; } }
05-23-2020 08:27 AM
I solved the problem by synchronizing insert calls. See code below:
private static Object lockingObjectInsert = new Object();
private Response<NodeRepresentation> insertSynchronized(Document documentEntity,NodeBodyCreate documentBody) throws IOException { synchronized (lockingObjectInsert) { Response<NodeRepresentation> responseCreate = getNodesAPI().createNodeCall(getFolderId(documentEntity), documentBody,true,null,null).execute(); return responseCreate; } }
Explore our Alfresco products with the links below. Use labels to filter content by product module.