public void recoverSubscription(String clientId, String subscriptionName, MessageRecoveryListener listener) throws Exception {
EntityManager manager = adapter.beginEntityManager(null);
try {
StoredSubscription ss = findStoredSubscription(manager, clientId, subscriptionName);
Query query = manager.createQuery("select m from StoredMessageReference m where m.destination=?1 and m.id>?2 order by m.id asc");
query.setParameter(1, destinationName);
query.setParameter(2, ss.getLastAckedId());
for (StoredMessageReference m : (List<StoredMessageReference>)query.getResultList()) {
MessageId mid = new MessageId(m.getMessageId());
mid.setBrokerSequenceId(m.getId());
listener.recoverMessageReference(mid);
}