How to handle join hundreds of MUCs?

Suppose I’m participating to 100 groups in Whatsapp.

When I disconnect from the openfire, due to a network problem (for example) and the pong was not sent back to the server, I will automatically leave all of them (I need a small timeout on the server to notify other users on the MUC when the user will be with slow connection and messages are not arriving).

But when reconnected, I should rejoin all of them again. In my java app using smack, I have in memory the list of joined rooms, so I’m spawing threads to join all of them again in parallel, because it can be a lot slow between joins. Is that the right way to handle this? I would like to know what is a good practice and how most of apps implement this.


Is there a reason you need to use MUC versus PubSub?

Thanks for your response. I think MUC it’s more appropriate because it will handle better the exchange of messages (chat) and presence are integrated (as far as I know). However, what advantages do you think PubSub provides? It will be more fast and lightweight in the batch join scenario?