Another thing, is there any property to keep the client alive and listening till all the messages on a particular topic are received.
What I am doing now is putting a while loop with a counter of the number of messages I want to receive and a sleep inside it.