You can only receive messages from people you are connected with. To be connected with someone, you have to accept their connection request. Then they can send you messages.
If you wish to stop receiving messages from someone, you can leave a conversation, remove them from a conversation, or block them at any time for any reason.