How to determine the primary message group of a message?