return initalized.get () ? result : null;
}
public MessageId getPreviousMessageIdToDeliver(String clientId,String subscriptionName,MessageId id) throws Exception{
final MessageId result = new MessageId();
final AtomicBoolean initalized = new AtomicBoolean();
TransactionContext c = persistenceAdapter.getTransactionContext();
try {
long sequence = id != null ? id.getBrokerSequenceId() : -1;
adapter.doGetPrevDurableSubscriberMessageIdStatement(c, destination, clientId, subscriptionName,sequence,new JDBCMessageRecoveryListener() {
public void recoverMessage(long sequenceId, byte[] data) throws Exception {
Message msg = (Message) wireFormat.unmarshal(new ByteSequence(data));
msg.getMessageId().setBrokerSequenceId(sequenceId);
result.setProducerId(msg.getMessageId().getProducerId());
result.setProducerSequenceId(msg.getMessageId().getProducerSequenceId());
result.setBrokerSequenceId(msg.getMessageId().getBrokerSequenceId());
initalized.set(true);
}
public void recoverMessageReference(String reference) throws Exception {
result.setValue(reference);
initalized.set(true);
}
public void finished(){
}
});
} catch (SQLException e) {
JDBCPersistenceAdapter.log("JDBC Failure: ",e);
throw IOExceptionSupport.create("Failed to get next MessageId to deliver: " + clientId + ". Reason: " + e, e);
} finally {
c.close();
}
return initalized.get () ? result : null;
}