Resolved concurrency issue when registering and publishing messages