I recall this story whenever I find myself complaining of my situations. Irrespective of our situations, we can always find Inner Peace by controlling our reactions to our situations. When you see a shadow, you know that the sun is shining, therefore instead of focusing on the negatives of life, look out for the opportunities and the bright side of life!
I heard this story the first time in one of the lectures by Br Khalil Jaffer in the series The Art of Yearning for God. I also read it in a book of Sufi stories.
One of the lessons to learn in this story is that we if recite the Names of God, it should be done with our hearts so that it takes effect. There is little benefit if we just recite it with our tongues while our heart is somewhere else.