/** * @return * @throws IOException * @see org.apache.activemq.store.MessageStore#getMessageCount() */ public int getMessageCount() throws IOException { flush(); return referenceStore.getMessageCount(); }
/** * @see org.apache.activemq.store.MessageStore#removeAllMessages(ConnectionContext) */ public void removeAllMessages(ConnectionContext context) throws IOException { flush(); referenceStore.removeAllMessages(context); }
public void dispose(ConnectionContext context) { try { flush(); } catch (InterruptedIOException e) { Thread.currentThread().interrupt(); } referenceStore.dispose(context); super.dispose(context); }
public void setBatch(MessageId messageId) { try { flush(); } catch (InterruptedIOException e) { LOG.debug("flush on setBatch resulted in exception", e); } getReferenceStore().setBatch(messageId); }
/** * Replays the referenceStore first as those messages are the oldest ones, then messages are replayed from the * transaction log and then the cache is updated. * * @param listener * @throws Exception */ public void recover(final MessageRecoveryListener listener) throws Exception { flush(); referenceStore.recover(new RecoveryListenerAdapter(this, listener)); }
public void stop() throws Exception { flush(); asyncWriteTask.shutdown(); referenceStore.stop(); }
final void removeMessage(final MessageAck ack, final Location location) throws InterruptedIOException { ReferenceData data; lock.lock(); try { lastLocation = location; MessageId id = ack.getLastMessageId(); data = messages.remove(id); if (data == null) { messageAcks.add(new MessageAckWithLocation(ack, location)); } else { // message never got written so datafileReference will still exist AMQMessageStore.this.peristenceAdapter.removeInProgressDataFile(AMQMessageStore.this, data.getFileId()); } } finally { lock.unlock(); } if (messageAcks.size() > this.peristenceAdapter.getMaxCheckpointMessageAddSize()) { flush(); } else if (data == null) { try { asyncWriteTask.wakeup(); } catch (InterruptedException e) { throw new InterruptedIOException(); } } }
public void recoverNextMessages(int maxReturned, MessageRecoveryListener listener) throws Exception { RecoveryListenerAdapter recoveryListener = new RecoveryListenerAdapter(this, listener); referenceStore.recoverNextMessages(maxReturned, recoveryListener); if (recoveryListener.size() == 0 && recoveryListener.hasSpace()) { flush(); referenceStore.recoverNextMessages(maxReturned, recoveryListener); } }
final void addMessage(final Message message, final Location location) throws InterruptedIOException { ReferenceData data = new ReferenceData(); data.setExpiration(message.getExpiration()); data.setFileId(location.getDataFileId()); data.setOffset(location.getOffset()); lock.lock(); try { lastLocation = location; ReferenceData prev = messages.put(message.getMessageId(), data); if (prev != null) { AMQMessageStore.this.peristenceAdapter.removeInProgressDataFile(AMQMessageStore.this, prev.getFileId()); } } finally { lock.unlock(); } if (messages.size() > this.peristenceAdapter.getMaxCheckpointMessageAddSize()) { flush(); } else { try { asyncWriteTask.wakeup(); } catch (InterruptedException e) { throw new InterruptedIOException(); } } }