@Override public synchronized int getSize() { return message.getSize(); }
synchronized long messageSize() { long messageSize = 0; for (Iterator<Entry<MessageId, Message>> iter = map.entrySet().iterator(); iter.hasNext();) { Entry<MessageId, Message> entry = iter.next(); messageSize += entry.getValue().getSize(); } return messageSize; }
@Override protected boolean removeEldestEntry(Map.Entry<Object,Command> eldest) { boolean result = currentCacheSize > maxCacheSize; if (result) { if (eldest.getValue() instanceof Message) { currentCacheSize -= ((Message)eldest.getValue()).getSize(); } else if (eldest.getValue() instanceof MessagePull) { currentCacheSize -= MESSAGE_PULL_SIZE; } if (LOG.isTraceEnabled()) { LOG.trace("removing tracked message: " + eldest.getKey()); } } return result; } };
public void add(MessageReference messageRef) { Message message = messageRef.getMessageHardRef(); int delta = message.getSize(); int newSize = 0; synchronized (lock) { list.add(messageRef); size += delta; newSize = size; } buffer.onSizeChanged(this, delta, newSize); }
public PendingMarshalUsageTracker(final Message message) { usage = message.getMemoryUsage(); if (usage != null) { messageSize = message.getSize(); usage.increaseUsage(messageSize); } }
private void logSend(Message copy) { copy.getSize(); Logger perDestinationsLogger = LOG; if (isPerDestinationLogger()) { ActiveMQDestination destination = copy.getDestination(); perDestinationsLogger = LoggerFactory.getLogger(LOG.getName() + "." + destination.getDestinationTypeAsString() + "." + destination.getPhysicalName()); } perDestinationsLogger.info("Sending message: {}", copy); }
@Override public int incrementReferenceCount() { int rc; int size; synchronized (this) { rc = ++referenceCount; size = getSize(); } if (rc == 1 && getMemoryUsage() != null) { getMemoryUsage().increaseUsage(size); //System.err.println("INCREASE USAGE " + System.identityHashCode(getMemoryUsage()) + " PERCENT = " + getMemoryUsage().getPercentUsage()); } //System.out.println(" + "+getMemoryUsage().getName()+" :::: "+getMessageId()+"rc="+rc); return rc; }
@Override public int decrementReferenceCount() { int rc; int size; synchronized (this) { rc = --referenceCount; size = getSize(); } if (rc == 0 && getMemoryUsage() != null) { getMemoryUsage().decreaseUsage(size); //Thread.dumpStack(); //System.err.println("DECREADED USAGE " + System.identityHashCode(getMemoryUsage()) + " PERCENT = " + getMemoryUsage().getPercentUsage()); } //System.out.println(" - "+getMemoryUsage().getName()+" :::: "+getMessageId()+"rc="+rc); return rc; }
final void messageSent(final ConnectionContext context, final Message msg) throws Exception { pendingSends.decrementAndGet(); destinationStatistics.getEnqueues().increment(); destinationStatistics.getMessages().increment(); destinationStatistics.getMessageSize().addSize(msg.getSize()); messageDelivered(context, msg); consumersLock.readLock().lock(); try { if (consumers.isEmpty()) { onMessageWithNoConsumers(context, msg); } }finally { consumersLock.readLock().unlock(); } LOG.debug("{} Message {} sent to {}", new Object[]{ broker.getBrokerName(), msg.getMessageId(), this.destination }); wakeup(); }
protected static final void incMessageStoreStatistics(final MessageStoreStatistics stats, final Message message) { if (stats != null && message != null) { stats.getMessageCount().increment(); stats.getMessageSize().addSize(message.getSize()); } }
protected static final void decMessageStoreStatistics(final MessageStoreStatistics stats, final Message message) { if (stats != null && message != null) { stats.getMessageCount().decrement(); stats.getMessageSize().addSize(-message.getSize()); } } }
@Override public void updateMessage(Message message) { synchronized (messageTable) { Message original = messageTable.get(message.getMessageId()); // if can't be found then increment count, else remove old size if (original == null) { getMessageStoreStatistics().getMessageCount().increment(); } else { getMessageStoreStatistics().getMessageSize().addSize(-original.getSize()); } messageTable.put(message.getMessageId(), message); getMessageStoreStatistics().getMessageSize().addSize(message.getSize()); } }
/** * Completes the two phase tracking operation for a command that is sent on the wire. Once * the command is sent successfully to complete the tracking operation or otherwise update * the state of the tracker. * * @param command * The command that was previously provided to the track method. */ public void trackBack(Command command) { if (command != null) { if (trackMessages && command.isMessage()) { Message message = (Message) command; if (message.getTransactionId()==null) { currentCacheSize = currentCacheSize + message.getSize(); } } else if (command instanceof MessagePull) { // We only track one MessagePull per consumer so only add to cache size // when the command has been marked as tracked. if (((MessagePull)command).isTracked()) { // just needs to be a rough estimate of size, ~4 identifiers currentCacheSize += MESSAGE_PULL_SIZE; } } } }
LOG.warn("Message could not be added to long term store: " + e.getMessage(), e); size += message.getSize(); message.decrementReferenceCount();
@Override public void recoverMessageStoreStatistics() throws IOException { synchronized (messageTable) { long size = 0; int count = 0; for (Message message : messageTable.values()) { size += message.getSize(); } getMessageStoreStatistics().reset(); getMessageStoreStatistics().getMessageCount().setCount(count); getMessageStoreStatistics().getMessageSize().setTotalSize(size); } }
destinationStatistics.getMessageSize().addSize(message.getSize()); MessageEvaluationContext msgContext = null;
.getSize()); context.getConnection().dispatchAsync(ack); } else {
@Override public void run() { try { // While waiting for space to free up... the // message may have expired. if (message.isExpired()) { broker.messageExpired(context, message, null); getDestinationStatistics().getExpired().increment(); } else { doMessageSend(producerExchange, message); } if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message .getSize()); context.getConnection().dispatchAsync(ack); } else { Response response = new Response(); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } } catch (Exception e) { if (!sendProducerAck && !context.isInRecoveryMode()) { ExceptionResponse response = new ExceptionResponse(e); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } } } });