For MQTT versions 3.1.1 and 5.0, look for the DUP flag in the MQTT header. This is set when a message is resent. Note, however, that the DUP flag will not help for QoS 0 messages, as these messages do not get re-delivered.