It's all about the answers!

Ask a question

How to serialize the programmatically comment insertion?


SEC Servizi (97123860) | asked Jul 12 '12, 4:23 a.m.
edited Jul 12 '12, 4:24 a.m.
 We have a Plain Java Client to programmatically add comments to existing work-items.
The snippet of code we use is:
ITeamRepository repo = ...
String msg = ...
WorkItemWorkingCopy workingCopy = ...
IWorkItem wiFreshCopy = workingCopy.getWorkItem();
IComments comments = wiFreshCopy.getComments();
IComment comment = comments.createComment(repo.loggedInContributor(), XMLString.createFromPlainText(msg));
comments.append(comment);
workingCopy.save(null);
When two (or more) processes try to add a new comment to the same work-item at the same time, only the last comment will be included.
How can we serialize the comment insertion? Why using a working copy is not enough?
Thanks in advance.
Cheers.

One answer



permanent link
SEC Servizi (97123860) | answered Oct 05 '12, 10:33 a.m.
We have tried to add the condition:
while (workingCopy.isDirty());
	
before add a new comment, but obviosly it is not enough...

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.