@Override public synchronized LinkedList<MessageReference> pageInList(int maxItems) { LinkedList<MessageReference> result = new LinkedList<MessageReference>(); int count = 0; for (Iterator<MessageReference> i = memoryList.iterator(); i.hasNext() && count < maxItems;) { MessageReference ref = i.next(); ref.incrementReferenceCount(); result.add(ref); count++; } if (count < maxItems && !isDiskListEmpty()) { for (Iterator<MessageReference> i = new DiskIterator(); i.hasNext() && count < maxItems;) { Message message = (Message) i.next(); message.setRegionDestination(regionDestination); message.setMemoryUsage(this.getSystemUsage().getMemoryUsage()); message.incrementReferenceCount(); result.add(message); count++; } } return result; }
/** * @return the next pending message */ @Override public synchronized MessageReference next() { MessageReference reference = iter.next(); last = reference; if (!isDiskListEmpty()) { // got from disk reference.getMessage().setRegionDestination(regionDestination); reference.getMessage().setMemoryUsage(this.getSystemUsage().getMemoryUsage()); } reference.incrementReferenceCount(); return reference; }
private void doForward(ProducerBrokerExchange context, Message message, Broker regionBroker, ActiveMQDestination destination) throws Exception { Message forwardedMessage = message.copy(); forwardedMessage.setMemoryUsage(null); forwardedMessage.setOriginalDestination( message.getDestination() ); forwardedMessage.setDestination(destination); // Send it back through the region broker for routing. context.setMutable(true); regionBroker.send(context, forwardedMessage); } }
public void send(ProducerBrokerExchange context, Message message) throws Exception { message.setDestination(mirrorDestination.getActiveMQDestination()); mirrorDestination.send(context, message); if (isCopyMessage()) { message = message.copy(); } message.setDestination(destination.getActiveMQDestination()); message.setMemoryUsage(null); // set this to null so that it will use the queue memoryUsage instance instead of the topic. super.send(context, message); } };
@Override public Response processMessageDispatch(MessageDispatch md) throws Exception { waitForTransportInterruptionProcessingToComplete(); ActiveMQDispatcher dispatcher = dispatchers.get(md.getConsumerId()); if (dispatcher != null) { // Copy in case a embedded broker is dispatching via // vm:// // md.getMessage() == null to signal end of queue // browse. Message msg = md.getMessage(); if (msg != null) { msg = msg.copy(); msg.setReadOnlyBody(true); msg.setReadOnlyProperties(true); msg.setRedeliveryCounter(md.getRedeliveryCounter()); msg.setConnection(ActiveMQConnection.this); msg.setMemoryUsage(null); md.setMessage(msg); } dispatcher.dispatch(md); } else { LOG.debug("{} no dispatcher for {} in {}", this, md, dispatchers); } return null; }
/** * */ public void send(ProducerBrokerExchange producerExchange, Message message) throws Exception { ActiveMQDestination destination = message.getDestination(); if (destination.isComposite()) { ActiveMQDestination[] destinations = destination.getCompositeDestinations(); for (int i = 0; i < destinations.length; i++) { if (i != 0) { message = message.copy(); message.setMemoryUsage(null); } message.setOriginalDestination(destination); message.setDestination(destinations[i]); next.send(producerExchange, message); } } else { next.send(producerExchange, message); } }
if (!cached) { if( message.getMemoryUsage()==null ) { message.setMemoryUsage(this.getSystemUsage().getMemoryUsage());
private void scheduleRedelivery(ConnectionContext context, MessageReference messageReference, long delay, int redeliveryCount) throws Exception { if (LOG.isTraceEnabled()) { Destination regionDestination = (Destination) messageReference.getRegionDestination(); LOG.trace("redelivery #{} of: {} with delay: {}, dest: {}", new Object[]{ redeliveryCount, messageReference.getMessageId(), delay, regionDestination.getActiveMQDestination() }); } final Message old = messageReference.getMessage(); Message message = old.copy(); message.setTransactionId(null); message.setMemoryUsage(null); message.removeProperty(ScheduledMessage.AMQ_SCHEDULED_ID); message.setProperty(REDELIVERY_DELAY, delay); message.setProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay); message.setRedeliveryCounter(redeliveryCount); boolean originalFlowControl = context.isProducerFlowControl(); try { context.setProducerFlowControl(false); ProducerInfo info = new ProducerInfo(); ProducerState state = new ProducerState(info); ProducerBrokerExchange producerExchange = new ProducerBrokerExchange(); producerExchange.setProducerState(state); producerExchange.setMutable(true); producerExchange.setConnectionContext(context); context.getBroker().send(producerExchange, message); } finally { context.setProducerFlowControl(originalFlowControl); } }
protected Message configureMessage(MessageDispatch md) throws IOException { Message message = md.getMessage().copy(); // Update the packet to show where it came from. message.setBrokerPath(appendToBrokerPath(message.getBrokerPath(), localBrokerPath)); message.setProducerId(producerInfo.getProducerId()); message.setDestination(md.getDestination()); message.setMemoryUsage(null); if (message.getOriginalTransactionId() == null) { message.setOriginalTransactionId(message.getTransactionId()); } message.setTransactionId(null); if (configuration.isUseCompression()) { message.compress(); } return message; }
public static void doResend(final ConnectionContext context, Message originalMessage, ActiveMQDestination deadLetterDestination, boolean copy) throws Exception { Message message = copy ? originalMessage.copy() : originalMessage; message.setOriginalDestination(message.getDestination()); message.setOriginalTransactionId(message.getTransactionId()); message.setDestination(deadLetterDestination); message.setTransactionId(null); message.setMemoryUsage(null); message.setRedeliveryCounter(0); message.getMessageId().setDataLocator(null); boolean originalFlowControl = context.isProducerFlowControl(); try { context.setProducerFlowControl(false); ProducerInfo info = new ProducerInfo(); ProducerState state = new ProducerState(info); ProducerBrokerExchange producerExchange = new ProducerBrokerExchange(); producerExchange.setProducerState(state); producerExchange.setMutable(true); producerExchange.setConnectionContext(context); context.getBroker().send(producerExchange, message); } finally { context.setProducerFlowControl(originalFlowControl); } }
/** * @return the next pending message */ @Override public synchronized MessageReference next() { Message message = (Message) iter.next(); last = message; if (!isDiskListEmpty()) { // got from disk message.setRegionDestination(regionDestination); message.setMemoryUsage(this.getSystemUsage().getMemoryUsage()); } message.incrementReferenceCount(); return message; }
private void doForward(ProducerBrokerExchange context, Message message, Broker regionBroker, ActiveMQDestination destination) throws Exception { Message forwardedMessage = message.copy(); forwardedMessage.setMemoryUsage(null); forwardedMessage.setOriginalDestination( message.getDestination() ); forwardedMessage.setDestination(destination); // Send it back through the region broker for routing. context.setMutable(true); regionBroker.send(context, forwardedMessage); } }
/** * @return the next pending message */ @Override public synchronized MessageReference next() { MessageReference reference = iter.next(); last = reference; if (!isDiskListEmpty()) { // got from disk reference.getMessage().setRegionDestination(regionDestination); reference.getMessage().setMemoryUsage(this.getSystemUsage().getMemoryUsage()); } reference.incrementReferenceCount(); return reference; }
/** * @return the next pending message */ @Override public synchronized MessageReference next() { MessageReference reference = iter.next(); last = reference; if (!isDiskListEmpty()) { // got from disk reference.getMessage().setRegionDestination(regionDestination); reference.getMessage().setMemoryUsage(this.getSystemUsage().getMemoryUsage()); } reference.incrementReferenceCount(); return reference; }
private void doForward(ProducerBrokerExchange context, Message message, Broker regionBroker, ActiveMQDestination destination) throws Exception { Message forwardedMessage = message.copy(); forwardedMessage.setMemoryUsage(null); forwardedMessage.setOriginalDestination( message.getDestination() ); forwardedMessage.setDestination(destination); // Send it back through the region broker for routing. context.setMutable(true); regionBroker.send(context, forwardedMessage); } }
private void doForward(ProducerBrokerExchange context, Message message, Broker regionBroker, ActiveMQDestination destination) throws Exception { Message forwardedMessage = message.copy(); forwardedMessage.setMemoryUsage(null); forwardedMessage.setOriginalDestination( message.getDestination() ); forwardedMessage.setDestination(destination); // Send it back through the region broker for routing. context.setMutable(true); regionBroker.send(context, forwardedMessage); } }
public void send(ProducerBrokerExchange context, Message message) throws Exception { message.setDestination(mirrorDestination.getActiveMQDestination()); mirrorDestination.send(context, message); if (isCopyMessage()) { message = message.copy(); } message.setDestination(destination.getActiveMQDestination()); message.setMemoryUsage(null); // set this to null so that it will use the queue memoryUsage instance instead of the topic. super.send(context, message); } };
public void send(ProducerBrokerExchange context, Message message) throws Exception { message.setDestination(mirrorDestination.getActiveMQDestination()); mirrorDestination.send(context, message); if (isCopyMessage()) { message = message.copy(); } message.setDestination(destination.getActiveMQDestination()); message.setMemoryUsage(null); // set this to null so that it will use the queue memoryUsage instance instead of the topic. super.send(context, message); } };
public void send(ProducerBrokerExchange context, Message message) throws Exception { message.setDestination(mirrorDestination.getActiveMQDestination()); mirrorDestination.send(context, message); if (isCopyMessage()) { message = message.copy(); } message.setDestination(destination.getActiveMQDestination()); message.setMemoryUsage(null); // set this to null so that it will use the queue memoryUsage instance instead of the topic. super.send(context, message); } };
protected Message configureMessage(MessageDispatch md) throws IOException { Message message = md.getMessage().copy(); // Update the packet to show where it came from. message.setBrokerPath(appendToBrokerPath(message.getBrokerPath(), localBrokerPath)); message.setProducerId(producerInfo.getProducerId()); message.setDestination(md.getDestination()); message.setMemoryUsage(null); if (message.getOriginalTransactionId() == null) { message.setOriginalTransactionId(message.getTransactionId()); } message.setTransactionId(null); if (configuration.isUseCompression()) { message.compress(); } return message; }