@Override public MessageReference copy(final Queue queue) { return new PagedReferenceImpl(this.position, this.getPagedMessage(), this.subscription); }
@Override public void acknowledge(Transaction tx) throws Exception { acknowledge(tx, null); }
@Override public boolean isLargeMessage() { if (largeMessage == UNDEFINED_IS_LARGE_MESSAGE && message != null) { initializeIsLargeMessage(); } return largeMessage == IS_LARGE_MESSAGE; }
@Override public SimpleString getLastValueProperty() { SimpleString lastValue = getMessage().getSimpleStringProperty(getQueue().getLastValueKey()); if (lastValue == null) { lastValue = getMessage().getLastValueProperty(); } return lastValue; }
@Override public String toString() { String msgToString; try { msgToString = getPagedMessage().toString(); } catch (Throwable e) { // in case of an exception because of a missing page, we just want toString to return null msgToString = "error:" + e.getMessage(); } return "PagedReferenceImpl [position=" + position + ", message=" + msgToString + ", deliveryTime=" + (deliveryTime == UNDEFINED_DELIVERY_TIME ? null : deliveryTime) + ", persistedCount=" + persistedCount + ", deliveryCount=" + deliveryCount + ", subscription=" + subscription + "]"; }
@Override public boolean isDurable() { if (durable == UNDEFINED_IS_DURABLE) { durable = getMessage().isDurable() ? IS_DURABLE : IS_NOT_DURABLE; } return durable == IS_DURABLE; }
@Override public PagedReference newReference(final PagePosition pos, final PagedMessage msg, final PageSubscription subscription) { return new PagedReferenceImpl(pos, msg, subscription); }
public PagedReferenceImpl(final PagePosition position, final PagedMessage message, final PageSubscription subscription) { this.position = position; this.message = new WeakReference<>(message); this.subscription = subscription; if (message != null) { this.largeMessage = message.getMessage().isLargeMessage() ? IS_LARGE_MESSAGE : IS_NOT_LARGE_MESSAGE; this.transactionID = message.getTransactionID(); this.messageID = message.getMessage().getMessageID(); this.durable = message.getMessage().isDurable() ? IS_DURABLE : IS_NOT_DURABLE; this.deliveryTime = message.getMessage().getScheduledDeliveryTime(); //pre-cache the message size so we don't have to reload the message later if it is GC'd getPersistentSize(); } else { this.largeMessage = UNDEFINED_IS_LARGE_MESSAGE; this.transactionID = -2; this.messageID = -1; this.messageSize = -1; this.durable = UNDEFINED_IS_DURABLE; this.deliveryTime = UNDEFINED_DELIVERY_TIME; } }
@Override public long getTransactionID() { if (transactionID < -1) { transactionID = getPagedMessage().getTransactionID(); } return transactionID; }
private void initializeIsLargeMessage() { assert largeMessage == UNDEFINED_IS_LARGE_MESSAGE && message != null; largeMessage = getMessage().isLargeMessage() ? IS_LARGE_MESSAGE : IS_NOT_LARGE_MESSAGE; }
@Override public void handled() { getQueue().referenceHandled(this); }
referencesToAck.add(new PagedReferenceImpl(encoding.position, null, sub)); } else { ActiveMQServerLogger.LOGGER.journalCannotFindQueueReloadingACK(encoding.queueID);
@Override public Message getMessage() { return getPagedMessage().getMessage(); }
@Override public long getScheduledDeliveryTime() { if (deliveryTime == UNDEFINED_DELIVERY_TIME) { try { Message msg = getMessage(); return msg.getScheduledDeliveryTime(); } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorCalculateScheduledDeliveryTime(e); return 0L; } } return deliveryTime; }
@Override public void acknowledge(Transaction tx, ServerConsumer consumer) throws Exception { acknowledge(tx, AckReason.NORMAL, consumer); }
@Override public long getMessageID() { if (messageID < 0) { messageID = getPagedMessage().getMessage().getMessageID(); } return messageID; }
@Override public int getMessageMemoryEstimate() { if (messageEstimate <= 0) { try { messageEstimate = getMessage().getMemoryEstimate(); } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorCalculateMessageMemoryEstimate(e); } } return messageEstimate; }
@Override public long getPersistentSize() { if (messageSize == -1) { try { messageSize = getPagedMessage().getPersistentSize(); } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorCalculatePersistentSize(e); } } return messageSize; }