public ReferenceData getMessageReference(MessageId identity) throws IOException {
ReferenceData rc = null;
EntityManager manager = adapter.beginEntityManager(null);
try {
StoredMessageReference message = null;
if (identity.getBrokerSequenceId() != 0) {
message = manager.find(StoredMessageReference.class, identity.getBrokerSequenceId());
} else {
Query query = manager.createQuery("select m from StoredMessageReference m where m.messageId=?1");
query.setParameter(1, identity.toString());
message = (StoredMessageReference)query.getSingleResult();
}
if (message != null) {
rc = new ReferenceData();
rc.setExpiration(message.getExiration());
rc.setFileId(message.getFileId());
rc.setOffset(message.getOffset());
}
} catch (Throwable e) {
adapter.rollbackEntityManager(null, manager);
throw IOExceptionSupport.create(e);
}