Goran,
I’m going to assume that you’re going to develop this application for this special purpose. Here’s an idea that comes off the top of my head; write a program that is allowed to have many instances running at the same time. However, when a message is being processed, the application must lock the person id so that other instances can’t work on that person at the same time. As long as all instances of the application can access the lock mechanism you can prevent the contention problem you describe.
What would be the possibility of the application listening on a socket? Then perhaps Cloverleaf could send the xml files directly to the application. Or what about using Cloverleaf to execute the SQL. Just random thoughts.
Cheers,