code: public void deleteMessages() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
          OfflineMessageRequest request = new OfflineMessageRequest();
          request.setType(IQ.Type.set);
          request.setPurge(true);
          connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
      }
docs: Deletes all offline messages of the user.
  
  @throws XMPPErrorException If the user is not allowed to make this request or the server does
  not support offline message retrieval.
  @throws NoResponseException if there was no response from the server.
  @throws NotConnectedException
  @throws InterruptedException