Tour page 23 of 28
This exercise will use weak notification to update a shared counter. In the example, many threads will concurrently try to update the counter but collisions will be avoided.
Create an observer that observes column ntfy:sum and make it do the following.
/and sum everything with that row prefix. Also delete the rows with that prefix.
Create a loader that does the following and run it 5000 times :
After the loader finishes, wait for observers and then print the value for counter001:sum:total. Since weak notifications are not transactional, all of the threads notifying the same row column should not collide.
One experiment to try is to use a smaller random number range and enable collision logging. For example try generating random numbers in the range of [0,99].