Working on a booking system I need to implement invoice numbering.
Invoice numbers must be sequential and with no gaps. i.e. 1, 2, 3 - is ok. 1, 3, 4 - is not ok.
In my present CRUD implementation I do a Lock, query over invoices table, generate new number, save and unlock.
How do you normally go about it? It must be a common scenario in many systems.
I could use a technique suggested in my other thread on scheduling: (https://groups.google.com/forum/#!topic/event-store/o_Y2exIxNZM)
i.e. introduce Invoicing aggregate to accept and number the invoice and then use Saga/ProcessManager to issue command to create the actual invoice.
Is this the best I can do or are there simpler solutions here?