How to handle the case for offline messages

How to handle the case for offline messages. for openfire the user is online in orphan case but the user is in real offline, so what will be the exception thrown by the route? and after catching that exception how to kill instantly that connection and store the message offline?

Note: orphan case is the case when the receiver just got offline and before getting the update router sends the message. so openfire thinks receiver is online while in real he is offline.