I would like to know which pattern is recommended to work with counter representing the number of message processed, with an application that should be stateless.
For example, in an architecture where an application is deployed on several servers, a database is used to store the persistent information (session, etc...). However, such information are not exposed to concurrent updates like a message counter would be. In a mono-instance application we could use singleton, but this is not the case here.
What would be your suggestion to implement a such counter ? Is using a counter a bad design ?
I may not be directly answering to your question, but I can give you a reference of a counter service available, which is multi threaded , multi noded, scalable and at the same time considers availability scenarios. Check the jgroups counter service http://jgroups.org/manual/index.html#CounterService.
This can guide you to a set of problems in the scenario of a distributed counter and also act as a live working reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With