if I understand your requirements you can add a persistence layer to your web application ( Hibernate if you don't want/cannot use an EJB container)
and store the amount of purchases there, which will be shared by the cluster.
Alternatively, if you want to set up a timer cluster-aware to monitor the sales, this can be done as well:
Hope this helps
Hi, i do have persistence layer using JPA and i use ejbs for my business&persistence logic. The problem is that my client wants every purchase request to be under 100ms and i can't afford to hit the data base.
Hi, i can't use HA singleton. And the data is not only per user - i can't keep the trucking count in the user's session. I will try to explain more what i want to do: The app has a collection of assets that may be from 1 to n; A user can place a purchase over an asset. My client wants "the purchase" to become manual (manual means the purchase must be confirmed by the admin who i watching a screen of manual purchase and process them) if for the current period(this must be scheduled by single timer in the cluster and on expire all counts will be reinitialized to 0): 1) the purchases for this asset are more than MAX_ASSET_PURCHASE_COUNT or if the sum of the purchases prices for the asset is more than MAX_ASSET_PURCHASES_PRICE. 2) the purchases for the user are more than MAX_USER_PURCHASE_COUNT(user specific) or if the sum of the purchases prices for the user is more than MAX_USER_PURCHASES_PRICE(user specific) 3) like 1) but not per asset and for all assets together. 4) like 2) but not per user and for all users together. The idea for one timer that is scheduled only by one of the jboss instances is great, but i can't make it to work, every thing is fine but when i kill the first jboss instance the second does not start the timer bean and does not schedule the timer(but i can see that it is deployed).So assuming i can make this to work in some way. I will make a service method that starts this timer from the jmx-console. I have external memcache that is visible from all instances. The purchases will be frequent like about 1000+ per minute. So i cant afford to update the memcache for every purchase. I was thinking about in memory cache for every jboss instance that tracks the counts and when the timer expires i get the counts from every inmemory cache and update the memcache and reinitialize the inmemory cache. The purchase servlet reads the memcache before purchase is done and decides over the above thresholds if the purchase has to go manual or not. So, any ideas? :) Regards.