org.apache.activemq.command.Message.getSize()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.apache.activemq.command.Message.getSize()方法的一些代码示例,展示了Message.getSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getSize()方法的具体详情如下:
包路径:org.apache.activemq.command.Message
类名称:Message
方法名:getSize

Message.getSize介绍

暂无

代码示例

代码示例来源:origin: apache/activemq

@Override
public synchronized int getSize() {
  return message.getSize();
}

代码示例来源:origin: apache/activemq

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;
}

代码示例来源:origin: apache/activemq

public void add(MessageReference node) {
  int delta = node.getMessageHardRef().getSize();
  synchronized (lock) {
    list.add(node);
    size += delta;
    while (size > maximumSize) {
      MessageReference evicted = list.removeFirst();
      size -= evicted.getMessageHardRef().getSize();
    }
  }
}

代码示例来源:origin: apache/activemq

@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;
  }
};

代码示例来源:origin: apache/activemq

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);
}

代码示例来源:origin: apache/activemq

public PendingMarshalUsageTracker(final Message message) {
  usage = message.getMemoryUsage();
  if (usage != null) {
    messageSize = message.getSize();
    usage.increaseUsage(messageSize);
  }
}

代码示例来源:origin: apache/activemq

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);
}

代码示例来源:origin: apache/activemq

@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;
}

代码示例来源:origin: apache/activemq

@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;
}

代码示例来源:origin: apache/activemq

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();
}

代码示例来源:origin: apache/activemq

protected static final void incMessageStoreStatistics(final MessageStoreStatistics stats, final Message message) {
  if (stats != null && message != null) {
    stats.getMessageCount().increment();
    stats.getMessageSize().addSize(message.getSize());
  }
}

代码示例来源:origin: apache/activemq

protected static final void decMessageStoreStatistics(final MessageStoreStatistics stats, final Message message) {
    if (stats != null && message != null) {
      stats.getMessageCount().decrement();
      stats.getMessageSize().addSize(-message.getSize());
    }
  }
}

代码示例来源:origin: apache/activemq

@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());
  }
}

代码示例来源:origin: apache/activemq

/**
 * 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;
      }
    }
  }
}

代码示例来源:origin: apache/activemq

LOG.warn("Message could not be added to long term store: " + e.getMessage(), e);
size += message.getSize();
message.decrementReferenceCount();

代码示例来源:origin: apache/activemq

@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);
  }
}

代码示例来源:origin: apache/activemq

destinationStatistics.getMessageSize().addSize(message.getSize());
MessageEvaluationContext msgContext = null;

代码示例来源:origin: apache/activemq

.getSize());
  context.getConnection().dispatchAsync(ack);
} else {

代码示例来源:origin: apache/activemq

@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);
      }
    }
  }
});

代码示例来源:origin: apache/activemq

ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message.getSize());
  context.getConnection().dispatchAsync(ack);
ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message.getSize());
context.getConnection().dispatchAsync(ack);

相关文章

微信公众号

最新文章

更多

Message类方法