cancel
Showing results for 
Search instead for 
Did you mean: 

Concurrent node children insert problem

mire323
Confirmed Champ
Confirmed Champ

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.

1 ACCEPTED ANSWER

mire323
Confirmed Champ
Confirmed Champ

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; } }

View answer in original post

1 REPLY 1

mire323
Confirmed Champ
Confirmed Champ

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; } }