Concurrent node children insert problem

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member II

Concurrent node children insert problem

Jump to solution

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 Solution

Accepted Solutions
Highlighted
Active Member II

Re: Concurrent node children insert problem

Jump to solution

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 solution in original post

1 Reply
Highlighted
Active Member II

Re: Concurrent node children insert problem

Jump to solution

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 solution in original post