You have created a new chat, each chat has a unique thread ID. This is the expected behaviour, as it allows for multiple unique chats to the same JID. Otherwise there is no way to distinguish messages between chat 1 and chat 2.
The issue you referenced deals with matching incoming chat messages that do not contain a thread id, as some clients don’t use them.
Thanks for your response rcollier. So what would be the right way to do this. Should I store a map between jid and Chat in order to reuse already created chats and avoid creating a new one for each message? Or is it just fine to create a new one for each message?
You would be expected to maintain and use the same Chat instance for the duration of your chat. Once created, the Chat is maintained in the ChatManager for the duration of your program. Incoming messages will be matched to the existing Chat and distributed to its listeners.
Creating a new Chat for each message will accumulate messages within the ChatManager, and produce unique chats (via threadId) to your user. If the end client uses the threadId and thus replies with it, the message will be sent to the Chat instance that matches.
Have you read the documentation with regards to Chat?