fixing a thread sleep issue in message broker