Web service Search and Create behaviour and thread safety

1
I am busy going through a codebase I have inherited and rarely I come across exceptions in the log to the tune of "com.mendix.systemwideinterfaces.MendixRuntimeException Found more than one MendixObject for xpathquery: //%s[%s='%s'] and arguments: Module.Entity, Attribute, UniqueKey" While this error is self explanatory in nature (there are duplicate objects with the same key), the root cause is quite a pain to determine. I was just wondering if this can be an issue where if a web service with "Search and Create" behaviour in the XML-to-Domain mapping can create duplicates if it is called in quick succession and there is signifacant latency to a database. I have tried looking for instances where these objects are created and comitted. What are the recommended ways to prevent this and what could be the most likely cause.
asked
1 answers
0

Since web service calls can be executed concurrently, and technically processed in two threads this can be the cause. You can solve this by not retrieving any data, but store the data in an intermediate structure and do the processing at one central place.

I would not recommend a high-frequent scheduled event because that has drawbacks. You can start a 'executeMicroflowInBackground' at the end of the web service microflow (which is just a set of commits), because this is a sequential execution. One microflow may process 2 webservice requests and the second none, but that is no problem.

answered