Publish and Subscribe Message mixed up [MQTT] [EC200]

I am subscribed to a certain topic. Periodically, I am publishing messages from device to mqtt broker. Sometimes, the incoming messages (for the topic we have subscribed) comes at the time of publishing message and overlaps with the response of Publish Message (something like this, +QMTPUBEX:). I have added flush function to clear out the response of publish but it also clears the incoming message. What are the best practices to manage this scenario?

Thanks

Hi @Chetan_Goyal
It can be distinguished by the urc prefix. The urc return of a successful pub is +QMTPUBEX:
The message received from the server is in the +QMTRECV: format.