Hi @Abhishek ,
Great you are interested in MQTT and HiveMQ client, welcome to the community !
Sounds like you need to implement offline message buffering. Please check out the example of offline message buffering implemented with HiveMQ MQTT Client here: Offline Message Buffering - #3 by Daria_H
I hope this helps,
Dasha from HiveMQ team