I want to avoid generating duplicate numbers in my system.
CreateNextNumber() will:
- Find the last number created.
- Increment the value by one.
- Update the value in the database with the new number.
I want to avoid two clients calling this method at the same time. My fear is they will pull the same last number created, increment it by one, and return the duplicate number for both clients.
Questions:
- Do I need to use single mode here? I'd rather use Per Call if possible.
- The default concurrency mode is single. I don't understand how Per Call would create multiple instances, yet have a single thread. Does that mean that even though multiple instances are created, only one client at a time can call a method in their instance?