Fixed possible race condition on message consumer thread