The scenario is as follows:
I’m using Apache CXF to expose web services to a client.
After receiving a request and processing it, I need to add a sequence number to the processed message header, and the I forward it to another program via MQ.
Also I use Spring to handle bean management and injection.
What’s the best way to manage a sequence without using a DB (since installing a DB just for sequence management seems to have an enormous overhead and bloat).
If the solution is to use a file (a properties file?), how can I opt for consistency if any exception occurs?
Also I need the sequence to be consistent when multiple requests arrive simultaneously.
If everything works within the same class loader, you could create a singleton with AtomicLong private field.