Prepend the unique key with the unique application id.
A1_102 file1.txt
A1_103 file2.txt
A1_104 file3.txt
and
A2_104 file5.txt
A2_105 file6.txt
A2_106 file7.txt
Each application produces a unique stream of document ids. The DB will only generate the number part, but you can prepend the application ID in the SQL statement:
SELECT Concat('A1_',file_num), filename FROM files;
You can do the same thing numerically by having one application start at a very high number, like 2,000,000,000. A third choice is to have one application produce even numbers (multiply by two) and the other odd numbers (multiple by 2 and add 1).