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

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

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

Message.setMemoryUsage介绍

暂无

代码示例

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

  1. @Override
  2. public synchronized LinkedList<MessageReference> pageInList(int maxItems) {
  3. LinkedList<MessageReference> result = new LinkedList<MessageReference>();
  4. int count = 0;
  5. for (Iterator<MessageReference> i = memoryList.iterator(); i.hasNext() && count < maxItems;) {
  6. MessageReference ref = i.next();
  7. ref.incrementReferenceCount();
  8. result.add(ref);
  9. count++;
  10. }
  11. if (count < maxItems && !isDiskListEmpty()) {
  12. for (Iterator<MessageReference> i = new DiskIterator(); i.hasNext() && count < maxItems;) {
  13. Message message = (Message) i.next();
  14. message.setRegionDestination(regionDestination);
  15. message.setMemoryUsage(this.getSystemUsage().getMemoryUsage());
  16. message.incrementReferenceCount();
  17. result.add(message);
  18. count++;
  19. }
  20. }
  21. return result;
  22. }

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

  1. /**
  2. * @return the next pending message
  3. */
  4. @Override
  5. public synchronized MessageReference next() {
  6. MessageReference reference = iter.next();
  7. last = reference;
  8. if (!isDiskListEmpty()) {
  9. // got from disk
  10. reference.getMessage().setRegionDestination(regionDestination);
  11. reference.getMessage().setMemoryUsage(this.getSystemUsage().getMemoryUsage());
  12. }
  13. reference.incrementReferenceCount();
  14. return reference;
  15. }

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

  1. private void doForward(ProducerBrokerExchange context, Message message, Broker regionBroker, ActiveMQDestination destination) throws Exception {
  2. Message forwardedMessage = message.copy();
  3. forwardedMessage.setMemoryUsage(null);
  4. forwardedMessage.setOriginalDestination( message.getDestination() );
  5. forwardedMessage.setDestination(destination);
  6. // Send it back through the region broker for routing.
  7. context.setMutable(true);
  8. regionBroker.send(context, forwardedMessage);
  9. }
  10. }

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

  1. public void send(ProducerBrokerExchange context, Message message) throws Exception {
  2. message.setDestination(mirrorDestination.getActiveMQDestination());
  3. mirrorDestination.send(context, message);
  4. if (isCopyMessage()) {
  5. message = message.copy();
  6. }
  7. message.setDestination(destination.getActiveMQDestination());
  8. message.setMemoryUsage(null); // set this to null so that it will use the queue memoryUsage instance instead of the topic.
  9. super.send(context, message);
  10. }
  11. };

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

  1. @Override
  2. public Response processMessageDispatch(MessageDispatch md) throws Exception {
  3. waitForTransportInterruptionProcessingToComplete();
  4. ActiveMQDispatcher dispatcher = dispatchers.get(md.getConsumerId());
  5. if (dispatcher != null) {
  6. // Copy in case a embedded broker is dispatching via
  7. // vm://
  8. // md.getMessage() == null to signal end of queue
  9. // browse.
  10. Message msg = md.getMessage();
  11. if (msg != null) {
  12. msg = msg.copy();
  13. msg.setReadOnlyBody(true);
  14. msg.setReadOnlyProperties(true);
  15. msg.setRedeliveryCounter(md.getRedeliveryCounter());
  16. msg.setConnection(ActiveMQConnection.this);
  17. msg.setMemoryUsage(null);
  18. md.setMessage(msg);
  19. }
  20. dispatcher.dispatch(md);
  21. } else {
  22. LOG.debug("{} no dispatcher for {} in {}", this, md, dispatchers);
  23. }
  24. return null;
  25. }

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

  1. /**
  2. *
  3. */
  4. public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception {
  5. ActiveMQDestination destination = message.getDestination();
  6. if (destination.isComposite()) {
  7. ActiveMQDestination[] destinations = destination.getCompositeDestinations();
  8. for (int i = 0; i < destinations.length; i++) {
  9. if (i != 0) {
  10. message = message.copy();
  11. message.setMemoryUsage(null);
  12. }
  13. message.setOriginalDestination(destination);
  14. message.setDestination(destinations[i]);
  15. next.send(producerExchange, message);
  16. }
  17. } else {
  18. next.send(producerExchange, message);
  19. }
  20. }

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

  1. if (!cached) {
  2. if( message.getMemoryUsage()==null ) {
  3. message.setMemoryUsage(this.getSystemUsage().getMemoryUsage());

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

  1. private void scheduleRedelivery(ConnectionContext context, MessageReference messageReference, long delay, int redeliveryCount) throws Exception {
  2. if (LOG.isTraceEnabled()) {
  3. Destination regionDestination = (Destination) messageReference.getRegionDestination();
  4. LOG.trace("redelivery #{} of: {} with delay: {}, dest: {}", new Object[]{
  5. redeliveryCount, messageReference.getMessageId(), delay, regionDestination.getActiveMQDestination()
  6. });
  7. }
  8. final Message old = messageReference.getMessage();
  9. Message message = old.copy();
  10. message.setTransactionId(null);
  11. message.setMemoryUsage(null);
  12. message.removeProperty(ScheduledMessage.AMQ_SCHEDULED_ID);
  13. message.setProperty(REDELIVERY_DELAY, delay);
  14. message.setProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);
  15. message.setRedeliveryCounter(redeliveryCount);
  16. boolean originalFlowControl = context.isProducerFlowControl();
  17. try {
  18. context.setProducerFlowControl(false);
  19. ProducerInfo info = new ProducerInfo();
  20. ProducerState state = new ProducerState(info);
  21. ProducerBrokerExchange producerExchange = new ProducerBrokerExchange();
  22. producerExchange.setProducerState(state);
  23. producerExchange.setMutable(true);
  24. producerExchange.setConnectionContext(context);
  25. context.getBroker().send(producerExchange, message);
  26. } finally {
  27. context.setProducerFlowControl(originalFlowControl);
  28. }
  29. }

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

  1. protected Message configureMessage(MessageDispatch md) throws IOException {
  2. Message message = md.getMessage().copy();
  3. // Update the packet to show where it came from.
  4. message.setBrokerPath(appendToBrokerPath(message.getBrokerPath(), localBrokerPath));
  5. message.setProducerId(producerInfo.getProducerId());
  6. message.setDestination(md.getDestination());
  7. message.setMemoryUsage(null);
  8. if (message.getOriginalTransactionId() == null) {
  9. message.setOriginalTransactionId(message.getTransactionId());
  10. }
  11. message.setTransactionId(null);
  12. if (configuration.isUseCompression()) {
  13. message.compress();
  14. }
  15. return message;
  16. }

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

  1. public static void doResend(final ConnectionContext context, Message originalMessage, ActiveMQDestination deadLetterDestination, boolean copy) throws Exception {
  2. Message message = copy ? originalMessage.copy() : originalMessage;
  3. message.setOriginalDestination(message.getDestination());
  4. message.setOriginalTransactionId(message.getTransactionId());
  5. message.setDestination(deadLetterDestination);
  6. message.setTransactionId(null);
  7. message.setMemoryUsage(null);
  8. message.setRedeliveryCounter(0);
  9. message.getMessageId().setDataLocator(null);
  10. boolean originalFlowControl = context.isProducerFlowControl();
  11. try {
  12. context.setProducerFlowControl(false);
  13. ProducerInfo info = new ProducerInfo();
  14. ProducerState state = new ProducerState(info);
  15. ProducerBrokerExchange producerExchange = new ProducerBrokerExchange();
  16. producerExchange.setProducerState(state);
  17. producerExchange.setMutable(true);
  18. producerExchange.setConnectionContext(context);
  19. context.getBroker().send(producerExchange, message);
  20. } finally {
  21. context.setProducerFlowControl(originalFlowControl);
  22. }
  23. }

代码示例来源:origin: pierre/meteo

  1. /**
  2. * @return the next pending message
  3. */
  4. @Override
  5. public synchronized MessageReference next() {
  6. Message message = (Message) iter.next();
  7. last = message;
  8. if (!isDiskListEmpty()) {
  9. // got from disk
  10. message.setRegionDestination(regionDestination);
  11. message.setMemoryUsage(this.getSystemUsage().getMemoryUsage());
  12. }
  13. message.incrementReferenceCount();
  14. return message;
  15. }

代码示例来源:origin: org.apache.activemq/activemq-broker

  1. private void doForward(ProducerBrokerExchange context, Message message, Broker regionBroker, ActiveMQDestination destination) throws Exception {
  2. Message forwardedMessage = message.copy();
  3. forwardedMessage.setMemoryUsage(null);
  4. forwardedMessage.setOriginalDestination( message.getDestination() );
  5. forwardedMessage.setDestination(destination);
  6. // Send it back through the region broker for routing.
  7. context.setMutable(true);
  8. regionBroker.send(context, forwardedMessage);
  9. }
  10. }

代码示例来源:origin: org.apache.activemq/activemq-broker

  1. /**
  2. * @return the next pending message
  3. */
  4. @Override
  5. public synchronized MessageReference next() {
  6. MessageReference reference = iter.next();
  7. last = reference;
  8. if (!isDiskListEmpty()) {
  9. // got from disk
  10. reference.getMessage().setRegionDestination(regionDestination);
  11. reference.getMessage().setMemoryUsage(this.getSystemUsage().getMemoryUsage());
  12. }
  13. reference.incrementReferenceCount();
  14. return reference;
  15. }

代码示例来源:origin: org.apache.activemq/activemq-all

  1. /**
  2. * @return the next pending message
  3. */
  4. @Override
  5. public synchronized MessageReference next() {
  6. MessageReference reference = iter.next();
  7. last = reference;
  8. if (!isDiskListEmpty()) {
  9. // got from disk
  10. reference.getMessage().setRegionDestination(regionDestination);
  11. reference.getMessage().setMemoryUsage(this.getSystemUsage().getMemoryUsage());
  12. }
  13. reference.incrementReferenceCount();
  14. return reference;
  15. }

代码示例来源:origin: org.apache.activemq/activemq-all

  1. private void doForward(ProducerBrokerExchange context, Message message, Broker regionBroker, ActiveMQDestination destination) throws Exception {
  2. Message forwardedMessage = message.copy();
  3. forwardedMessage.setMemoryUsage(null);
  4. forwardedMessage.setOriginalDestination( message.getDestination() );
  5. forwardedMessage.setDestination(destination);
  6. // Send it back through the region broker for routing.
  7. context.setMutable(true);
  8. regionBroker.send(context, forwardedMessage);
  9. }
  10. }

代码示例来源:origin: org.apache.activemq/activemq-osgi

  1. private void doForward(ProducerBrokerExchange context, Message message, Broker regionBroker, ActiveMQDestination destination) throws Exception {
  2. Message forwardedMessage = message.copy();
  3. forwardedMessage.setMemoryUsage(null);
  4. forwardedMessage.setOriginalDestination( message.getDestination() );
  5. forwardedMessage.setDestination(destination);
  6. // Send it back through the region broker for routing.
  7. context.setMutable(true);
  8. regionBroker.send(context, forwardedMessage);
  9. }
  10. }

代码示例来源:origin: org.apache.activemq/activemq-broker

  1. public void send(ProducerBrokerExchange context, Message message) throws Exception {
  2. message.setDestination(mirrorDestination.getActiveMQDestination());
  3. mirrorDestination.send(context, message);
  4. if (isCopyMessage()) {
  5. message = message.copy();
  6. }
  7. message.setDestination(destination.getActiveMQDestination());
  8. message.setMemoryUsage(null); // set this to null so that it will use the queue memoryUsage instance instead of the topic.
  9. super.send(context, message);
  10. }
  11. };

代码示例来源:origin: org.apache.activemq/activemq-all

  1. public void send(ProducerBrokerExchange context, Message message) throws Exception {
  2. message.setDestination(mirrorDestination.getActiveMQDestination());
  3. mirrorDestination.send(context, message);
  4. if (isCopyMessage()) {
  5. message = message.copy();
  6. }
  7. message.setDestination(destination.getActiveMQDestination());
  8. message.setMemoryUsage(null); // set this to null so that it will use the queue memoryUsage instance instead of the topic.
  9. super.send(context, message);
  10. }
  11. };

代码示例来源:origin: org.apache.activemq/activemq-osgi

  1. public void send(ProducerBrokerExchange context, Message message) throws Exception {
  2. message.setDestination(mirrorDestination.getActiveMQDestination());
  3. mirrorDestination.send(context, message);
  4. if (isCopyMessage()) {
  5. message = message.copy();
  6. }
  7. message.setDestination(destination.getActiveMQDestination());
  8. message.setMemoryUsage(null); // set this to null so that it will use the queue memoryUsage instance instead of the topic.
  9. super.send(context, message);
  10. }
  11. };

代码示例来源:origin: org.apache.activemq/activemq-all

  1. protected Message configureMessage(MessageDispatch md) throws IOException {
  2. Message message = md.getMessage().copy();
  3. // Update the packet to show where it came from.
  4. message.setBrokerPath(appendToBrokerPath(message.getBrokerPath(), localBrokerPath));
  5. message.setProducerId(producerInfo.getProducerId());
  6. message.setDestination(md.getDestination());
  7. message.setMemoryUsage(null);
  8. if (message.getOriginalTransactionId() == null) {
  9. message.setOriginalTransactionId(message.getTransactionId());
  10. }
  11. message.setTransactionId(null);
  12. if (configuration.isUseCompression()) {
  13. message.compress();
  14. }
  15. return message;
  16. }

相关文章

Message类方法