Advice in how to make externalId truly unique in Corda.

Luiz Silva

Although the class UniqueIdentifier assures uniqueness within Corda, reality is systems of records needs to interact with other systems. For example a billing system will have a unique invoiceId, or insurance will have claimsId. In this case their ids are unique in their systems.


In a flow when is called UniqueIdentifier(externalId = myInvoiceId) more than once, 2 or more linear state records will be created that refers to the same invoiceId. How to prevent this?


I wrote code in the flow to check uniqueness before finality and this works if subsequent request are processed after the completion of previous one.


But if this code fails when multiple are processed in parallel.


I am looking for solution that assure uniqueness and integrity of the data before flow reaches finality.