mercredi 10 novembre 2021

Generate AlphaNumeric String in Distributed Systems

There is a requirement in which i need to generate alphanumeric string having length 8.There are lot questions over stackoverflow but not able to find specific to my requirement.

Actually i need to generate barcode on which i need to show this string, i can generate as suggested in this stackoverlow question, but what if

  1. My application is running multiple instances there may be a case of having duplicate generated string.

  2. What happens when application restarts, as not maintaining states or last generated values.

I could use the Database like MySql with Unique key constraints to mitigate these issues but still i think(correct me please) it is not the standard way to implement this solution, because in this too i need to handle the exception of unique key constraints and try to generate again until got the unique value.




Aucun commentaire:

Enregistrer un commentaire