mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@957881 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eeacd65a2b
commit
00879cf683
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||||
import org.apache.activemq.command.MessageDispatch;
|
import org.apache.activemq.command.MessageDispatch;
|
||||||
|
|
||||||
public class SimplePriorityMessageDispatchChannel implements MessageDispatchChannel {
|
public class SimplePriorityMessageDispatchChannel implements MessageDispatchChannel {
|
||||||
private static Integer MAX_PRIORITY = 10;
|
private static final Integer MAX_PRIORITY = 10;
|
||||||
private final Object mutex = new Object();
|
private final Object mutex = new Object();
|
||||||
private final LinkedList<MessageDispatch>[] lists;
|
private final LinkedList<MessageDispatch>[] lists;
|
||||||
private boolean closed;
|
private boolean closed;
|
||||||
|
@ -234,7 +234,7 @@ public class SimplePriorityMessageDispatchChannel implements MessageDispatchChan
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getPriority(MessageDispatch message) {
|
protected int getPriority(MessageDispatch message) {
|
||||||
int priority = Message.DEFAULT_PRIORITY;
|
int priority = javax.jms.Message.DEFAULT_PRIORITY;
|
||||||
if (message.getMessage() != null) {
|
if (message.getMessage() != null) {
|
||||||
Math.max(message.getMessage().getPriority(), 0);
|
Math.max(message.getMessage().getPriority(), 0);
|
||||||
priority = Math.min(priority, 9);
|
priority = Math.min(priority, 9);
|
||||||
|
|
|
@ -16,19 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.broker.jmx;
|
package org.apache.activemq.broker.jmx;
|
||||||
|
|
||||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
|
||||||
import org.apache.activemq.broker.jmx.OpenTypeSupport.OpenTypeFactory;
|
|
||||||
import org.apache.activemq.broker.region.Destination;
|
|
||||||
import org.apache.activemq.broker.region.Subscription;
|
|
||||||
import org.apache.activemq.command.ActiveMQDestination;
|
|
||||||
import org.apache.activemq.command.ActiveMQMessage;
|
|
||||||
import org.apache.activemq.command.ActiveMQTextMessage;
|
|
||||||
import org.apache.activemq.command.Message;
|
|
||||||
import org.apache.activemq.filter.BooleanExpression;
|
|
||||||
import org.apache.activemq.filter.MessageEvaluationContext;
|
|
||||||
import org.apache.activemq.selector.SelectorParser;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -48,6 +35,19 @@ import javax.management.openmbean.OpenDataException;
|
||||||
import javax.management.openmbean.TabularData;
|
import javax.management.openmbean.TabularData;
|
||||||
import javax.management.openmbean.TabularDataSupport;
|
import javax.management.openmbean.TabularDataSupport;
|
||||||
import javax.management.openmbean.TabularType;
|
import javax.management.openmbean.TabularType;
|
||||||
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||||
|
import org.apache.activemq.broker.jmx.OpenTypeSupport.OpenTypeFactory;
|
||||||
|
import org.apache.activemq.broker.region.Destination;
|
||||||
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
|
import org.apache.activemq.command.ActiveMQDestination;
|
||||||
|
import org.apache.activemq.command.ActiveMQMessage;
|
||||||
|
import org.apache.activemq.command.ActiveMQTextMessage;
|
||||||
|
import org.apache.activemq.command.Message;
|
||||||
|
import org.apache.activemq.filter.BooleanExpression;
|
||||||
|
import org.apache.activemq.filter.MessageEvaluationContext;
|
||||||
|
import org.apache.activemq.selector.SelectorParser;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
public class DestinationView implements DestinationViewMBean {
|
public class DestinationView implements DestinationViewMBean {
|
||||||
private static final Log LOG = LogFactory.getLog(DestinationViewMBean.class);
|
private static final Log LOG = LogFactory.getLog(DestinationViewMBean.class);
|
||||||
|
@ -126,6 +126,10 @@ public class DestinationView implements DestinationViewMBean {
|
||||||
public long getMinEnqueueTime() {
|
public long getMinEnqueueTime() {
|
||||||
return destination.getDestinationStatistics().getProcessTime().getMinTime();
|
return destination.getDestinationStatistics().getProcessTime().getMinTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPrioritizedMessages() {
|
||||||
|
return destination.isPrioritizedMessages();
|
||||||
|
}
|
||||||
|
|
||||||
public CompositeData[] browse() throws OpenDataException {
|
public CompositeData[] browse() throws OpenDataException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -16,16 +16,15 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.broker.jmx;
|
package org.apache.activemq.broker.jmx;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import javax.jms.InvalidSelectorException;
|
import javax.jms.InvalidSelectorException;
|
||||||
|
import javax.management.MalformedObjectNameException;
|
||||||
|
import javax.management.ObjectName;
|
||||||
import javax.management.openmbean.CompositeData;
|
import javax.management.openmbean.CompositeData;
|
||||||
import javax.management.openmbean.OpenDataException;
|
import javax.management.openmbean.OpenDataException;
|
||||||
import javax.management.openmbean.TabularData;
|
import javax.management.openmbean.TabularData;
|
||||||
import javax.management.ObjectName;
|
|
||||||
import javax.management.MalformedObjectNameException;
|
|
||||||
|
|
||||||
public interface DestinationViewMBean {
|
public interface DestinationViewMBean {
|
||||||
|
|
||||||
|
@ -313,6 +312,12 @@ public interface DestinationViewMBean {
|
||||||
@MBeanInfo("Caching is enabled")
|
@MBeanInfo("Caching is enabled")
|
||||||
public boolean isUseCache();
|
public boolean isUseCache();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if prioritized messages are enabled for the destination
|
||||||
|
*/
|
||||||
|
@MBeanInfo("Prioritized messages is enabled")
|
||||||
|
public boolean isPrioritizedMessages();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param value
|
* @param value
|
||||||
* enable/disable caching on the destination
|
* enable/disable caching on the destination
|
||||||
|
|
|
@ -81,6 +81,7 @@ public abstract class BaseDestination implements Destination {
|
||||||
protected int cursorMemoryHighWaterMark = 70;
|
protected int cursorMemoryHighWaterMark = 70;
|
||||||
protected int storeUsageHighWaterMark = 100;
|
protected int storeUsageHighWaterMark = 100;
|
||||||
private SlowConsumerStrategy slowConsumerStrategy;
|
private SlowConsumerStrategy slowConsumerStrategy;
|
||||||
|
private boolean prioritizedMessages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param broker
|
* @param broker
|
||||||
|
@ -580,5 +581,14 @@ public abstract class BaseDestination implements Destination {
|
||||||
public void setSlowConsumerStrategy(SlowConsumerStrategy slowConsumerStrategy) {
|
public void setSlowConsumerStrategy(SlowConsumerStrategy slowConsumerStrategy) {
|
||||||
this.slowConsumerStrategy = slowConsumerStrategy;
|
this.slowConsumerStrategy = slowConsumerStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isPrioritizedMessages() {
|
||||||
|
return this.prioritizedMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrioritizedMessages(boolean prioritizedMessages) {
|
||||||
|
this.prioritizedMessages = prioritizedMessages;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,12 @@ package org.apache.activemq.broker.region;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.activemq.Service;
|
import org.apache.activemq.Service;
|
||||||
import org.apache.activemq.broker.ConnectionContext;
|
import org.apache.activemq.broker.ConnectionContext;
|
||||||
import org.apache.activemq.broker.ProducerBrokerExchange;
|
import org.apache.activemq.broker.ProducerBrokerExchange;
|
||||||
import org.apache.activemq.broker.region.policy.DeadLetterStrategy;
|
import org.apache.activemq.broker.region.policy.DeadLetterStrategy;
|
||||||
import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy;
|
import org.apache.activemq.broker.region.policy.SharedDeadLetterStrategy;
|
||||||
import org.apache.activemq.command.ActiveMQDestination;
|
import org.apache.activemq.command.ActiveMQDestination;
|
||||||
import org.apache.activemq.command.ConsumerInfo;
|
|
||||||
import org.apache.activemq.command.Message;
|
import org.apache.activemq.command.Message;
|
||||||
import org.apache.activemq.command.MessageAck;
|
import org.apache.activemq.command.MessageAck;
|
||||||
import org.apache.activemq.command.MessageDispatchNotification;
|
import org.apache.activemq.command.MessageDispatchNotification;
|
||||||
|
@ -215,4 +213,6 @@ public interface Destination extends Service, Task {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception;
|
void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception;
|
||||||
|
|
||||||
|
boolean isPrioritizedMessages();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.activemq.broker.region;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.activemq.broker.Broker;
|
import org.apache.activemq.broker.Broker;
|
||||||
import org.apache.activemq.broker.ConnectionContext;
|
import org.apache.activemq.broker.ConnectionContext;
|
||||||
import org.apache.activemq.broker.ProducerBrokerExchange;
|
import org.apache.activemq.broker.ProducerBrokerExchange;
|
||||||
|
@ -39,7 +38,7 @@ import org.apache.activemq.usage.Usage;
|
||||||
*/
|
*/
|
||||||
public class DestinationFilter implements Destination {
|
public class DestinationFilter implements Destination {
|
||||||
|
|
||||||
private Destination next;
|
private final Destination next;
|
||||||
|
|
||||||
public DestinationFilter(Destination next) {
|
public DestinationFilter(Destination next) {
|
||||||
this.next = next;
|
this.next = next;
|
||||||
|
@ -270,4 +269,8 @@ public class DestinationFilter implements Destination {
|
||||||
public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark) {
|
public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark) {
|
||||||
next.setCursorMemoryHighWaterMark(cursorMemoryHighWaterMark);
|
next.setCursorMemoryHighWaterMark(cursorMemoryHighWaterMark);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPrioritizedMessages() {
|
||||||
|
return next.isPrioritizedMessages();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.broker.region;
|
package org.apache.activemq.broker.region;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.apache.activemq.command.ConsumerId;
|
import org.apache.activemq.command.ConsumerId;
|
||||||
import org.apache.activemq.command.Message;
|
import org.apache.activemq.command.Message;
|
||||||
import org.apache.activemq.command.MessageId;
|
import org.apache.activemq.command.MessageId;
|
||||||
|
@ -33,7 +31,7 @@ public interface MessageReference {
|
||||||
|
|
||||||
MessageId getMessageId();
|
MessageId getMessageId();
|
||||||
Message getMessageHardRef();
|
Message getMessageHardRef();
|
||||||
Message getMessage() throws IOException;
|
Message getMessage();
|
||||||
boolean isPersistent();
|
boolean isPersistent();
|
||||||
|
|
||||||
Destination getRegionDestination();
|
Destination getRegionDestination();
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.broker.region;
|
package org.apache.activemq.broker.region;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.apache.activemq.command.ActiveMQMessage;
|
import org.apache.activemq.command.ActiveMQMessage;
|
||||||
import org.apache.activemq.command.ConsumerId;
|
import org.apache.activemq.command.ConsumerId;
|
||||||
import org.apache.activemq.command.Message;
|
import org.apache.activemq.command.Message;
|
||||||
|
@ -28,7 +26,7 @@ import org.apache.activemq.command.MessageId;
|
||||||
*/
|
*/
|
||||||
final class NullMessageReference implements QueueMessageReference {
|
final class NullMessageReference implements QueueMessageReference {
|
||||||
|
|
||||||
private ActiveMQMessage message = new ActiveMQMessage();
|
private final ActiveMQMessage message = new ActiveMQMessage();
|
||||||
private volatile int references;
|
private volatile int references;
|
||||||
|
|
||||||
public void drop() {
|
public void drop() {
|
||||||
|
@ -75,7 +73,7 @@ final class NullMessageReference implements QueueMessageReference {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message getMessage() throws IOException {
|
public Message getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ public abstract class PrefetchSubscription extends AbstractSubscription {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrefetchSubscription(Broker broker,SystemUsage usageManager, ConnectionContext context, ConsumerInfo info) throws InvalidSelectorException {
|
public PrefetchSubscription(Broker broker,SystemUsage usageManager, ConnectionContext context, ConsumerInfo info) throws InvalidSelectorException {
|
||||||
this(broker,usageManager,context, info, new VMPendingMessageCursor());
|
this(broker,usageManager,context, info, new VMPendingMessageCursor(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -236,7 +236,7 @@ public class Queue extends BaseDestination implements Task, UsageListener {
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
if (this.messages == null) {
|
if (this.messages == null) {
|
||||||
if (destination.isTemporary() || broker == null || store == null) {
|
if (destination.isTemporary() || broker == null || store == null) {
|
||||||
this.messages = new VMPendingMessageCursor();
|
this.messages = new VMPendingMessageCursor(isPrioritizedMessages());
|
||||||
} else {
|
} else {
|
||||||
this.messages = new StoreQueueCursor(broker, this);
|
this.messages = new StoreQueueCursor(broker, this);
|
||||||
}
|
}
|
||||||
|
@ -951,38 +951,30 @@ public class Queue extends BaseDestination implements Task, UsageListener {
|
||||||
|
|
||||||
public Message getMessage(String id) {
|
public Message getMessage(String id) {
|
||||||
MessageId msgId = new MessageId(id);
|
MessageId msgId = new MessageId(id);
|
||||||
try {
|
synchronized (pagedInMessages) {
|
||||||
synchronized (pagedInMessages) {
|
QueueMessageReference r = this.pagedInMessages.get(msgId);
|
||||||
QueueMessageReference r = this.pagedInMessages.get(msgId);
|
if (r != null) {
|
||||||
if (r != null) {
|
return r.getMessage();
|
||||||
return r.getMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
synchronized (messages) {
|
}
|
||||||
try {
|
synchronized (messages) {
|
||||||
messages.reset();
|
try {
|
||||||
while (messages.hasNext()) {
|
messages.reset();
|
||||||
try {
|
while (messages.hasNext()) {
|
||||||
MessageReference r = messages.next();
|
MessageReference r = messages.next();
|
||||||
r.decrementReferenceCount();
|
r.decrementReferenceCount();
|
||||||
messages.rollback(r.getMessageId());
|
messages.rollback(r.getMessageId());
|
||||||
if (msgId.equals(r.getMessageId())) {
|
if (msgId.equals(r.getMessageId())) {
|
||||||
Message m = r.getMessage();
|
Message m = r.getMessage();
|
||||||
if (m != null) {
|
if (m != null) {
|
||||||
return m;
|
return m;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.error("got an exception retrieving message " + id);
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
messages.release();
|
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
messages.release();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.error("got an exception retrieving message " + id);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class TempQueue extends Queue{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
this.messages=new VMPendingMessageCursor();
|
this.messages=new VMPendingMessageCursor(false);
|
||||||
this.messages.setMemoryUsageHighWaterMark(getCursorMemoryHighWaterMark());
|
this.messages.setMemoryUsageHighWaterMark(getCursorMemoryHighWaterMark());
|
||||||
this.systemUsage = brokerService.getSystemUsage();
|
this.systemUsage = brokerService.getSystemUsage();
|
||||||
memoryUsage.setParent(systemUsage.getMemoryUsage());
|
memoryUsage.setParent(systemUsage.getMemoryUsage());
|
||||||
|
|
|
@ -72,9 +72,9 @@ public class TopicSubscription extends AbstractSubscription {
|
||||||
this.usageManager = usageManager;
|
this.usageManager = usageManager;
|
||||||
String matchedName = "TopicSubscription:" + CURSOR_NAME_COUNTER.getAndIncrement() + "[" + info.getConsumerId().toString() + "]";
|
String matchedName = "TopicSubscription:" + CURSOR_NAME_COUNTER.getAndIncrement() + "[" + info.getConsumerId().toString() + "]";
|
||||||
if (info.getDestination().isTemporary() || broker == null || broker.getTempDataStore()==null ) {
|
if (info.getDestination().isTemporary() || broker == null || broker.getTempDataStore()==null ) {
|
||||||
this.matched = new VMPendingMessageCursor();
|
this.matched = new VMPendingMessageCursor(false);
|
||||||
} else {
|
} else {
|
||||||
this.matched = new FilePendingMessageCursor(broker,matchedName);
|
this.matched = new FilePendingMessageCursor(broker,matchedName,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,14 @@ package org.apache.activemq.broker.region.cursors;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import org.apache.activemq.ActiveMQMessageAudit;
|
import org.apache.activemq.ActiveMQMessageAudit;
|
||||||
|
import org.apache.activemq.broker.Broker;
|
||||||
import org.apache.activemq.broker.ConnectionContext;
|
import org.apache.activemq.broker.ConnectionContext;
|
||||||
import org.apache.activemq.broker.region.BaseDestination;
|
import org.apache.activemq.broker.region.BaseDestination;
|
||||||
import org.apache.activemq.broker.region.Destination;
|
import org.apache.activemq.broker.region.Destination;
|
||||||
import org.apache.activemq.broker.region.MessageReference;
|
import org.apache.activemq.broker.region.MessageReference;
|
||||||
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
import org.apache.activemq.command.MessageId;
|
import org.apache.activemq.command.MessageId;
|
||||||
import org.apache.activemq.usage.SystemUsage;
|
import org.apache.activemq.usage.SystemUsage;
|
||||||
|
|
||||||
|
@ -44,6 +47,11 @@ public abstract class AbstractPendingMessageCursor implements PendingMessageCurs
|
||||||
protected boolean useCache=true;
|
protected boolean useCache=true;
|
||||||
private boolean started=false;
|
private boolean started=false;
|
||||||
protected MessageReference last = null;
|
protected MessageReference last = null;
|
||||||
|
protected final boolean prioritizedMessages;
|
||||||
|
|
||||||
|
public AbstractPendingMessageCursor(boolean prioritizedMessages) {
|
||||||
|
this.prioritizedMessages=prioritizedMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public synchronized void start() throws Exception {
|
public synchronized void start() throws Exception {
|
||||||
|
@ -304,4 +312,19 @@ public abstract class AbstractPendingMessageCursor implements PendingMessageCurs
|
||||||
protected synchronized boolean isStarted() {
|
protected synchronized boolean isStarted() {
|
||||||
return started;
|
return started;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isPrioritizedMessageSubscriber(Broker broker,Subscription sub) {
|
||||||
|
boolean result = false;
|
||||||
|
Set<Destination> destinations = broker.getDestinations(sub.getActiveMQDestination());
|
||||||
|
if (destinations != null) {
|
||||||
|
for (Destination dest:destinations) {
|
||||||
|
if (dest.isPrioritizedMessages()) {
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
package org.apache.activemq.broker.region.cursors;
|
package org.apache.activemq.broker.region.cursors;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import org.apache.activemq.broker.region.Destination;
|
import org.apache.activemq.broker.region.Destination;
|
||||||
import org.apache.activemq.broker.region.MessageReference;
|
import org.apache.activemq.broker.region.MessageReference;
|
||||||
import org.apache.activemq.command.Message;
|
import org.apache.activemq.command.Message;
|
||||||
|
@ -34,8 +32,8 @@ import org.apache.commons.logging.LogFactory;
|
||||||
public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor implements MessageRecoveryListener {
|
public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor implements MessageRecoveryListener {
|
||||||
private static final Log LOG = LogFactory.getLog(AbstractStoreCursor.class);
|
private static final Log LOG = LogFactory.getLog(AbstractStoreCursor.class);
|
||||||
protected final Destination regionDestination;
|
protected final Destination regionDestination;
|
||||||
private final LinkedHashMap<MessageId,Message> batchList = new LinkedHashMap<MessageId,Message> ();
|
private final PendingList batchList;
|
||||||
private Iterator<Entry<MessageId, Message>> iterator = null;
|
private Iterator<MessageReference> iterator = null;
|
||||||
private boolean cacheEnabled=false;
|
private boolean cacheEnabled=false;
|
||||||
protected boolean batchResetNeeded = true;
|
protected boolean batchResetNeeded = true;
|
||||||
protected boolean storeHasMessages = false;
|
protected boolean storeHasMessages = false;
|
||||||
|
@ -43,10 +41,16 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
private MessageId lastCachedId;
|
private MessageId lastCachedId;
|
||||||
|
|
||||||
protected AbstractStoreCursor(Destination destination) {
|
protected AbstractStoreCursor(Destination destination) {
|
||||||
|
super((destination != null ? destination.isPrioritizedMessages():false));
|
||||||
this.regionDestination=destination;
|
this.regionDestination=destination;
|
||||||
|
if (this.prioritizedMessages) {
|
||||||
|
this.batchList= new PrioritizedPendingList();
|
||||||
|
}else {
|
||||||
|
this.batchList = new OrderedPendingList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized void start() throws Exception{
|
public final synchronized void start() throws Exception{
|
||||||
if (!isStarted()) {
|
if (!isStarted()) {
|
||||||
super.start();
|
super.start();
|
||||||
|
@ -60,7 +64,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized void stop() throws Exception {
|
public final synchronized void stop() throws Exception {
|
||||||
resetBatch();
|
resetBatch();
|
||||||
super.stop();
|
super.stop();
|
||||||
|
@ -82,7 +86,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
message.incrementReferenceCount();
|
message.incrementReferenceCount();
|
||||||
batchList.put(message.getMessageId(), message);
|
batchList.addMessageLast(message);
|
||||||
clearIterator(true);
|
clearIterator(true);
|
||||||
recovered = true;
|
recovered = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -99,7 +103,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
return recovered;
|
return recovered;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void reset() {
|
public final void reset() {
|
||||||
if (batchList.isEmpty()) {
|
if (batchList.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
|
@ -113,7 +117,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
size();
|
size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void release() {
|
public synchronized void release() {
|
||||||
clearIterator(false);
|
clearIterator(false);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +133,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
|
|
||||||
private synchronized void ensureIterator() {
|
private synchronized void ensureIterator() {
|
||||||
if(this.iterator==null) {
|
if(this.iterator==null) {
|
||||||
this.iterator=this.batchList.entrySet().iterator();
|
this.iterator=this.batchList.iterator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +141,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
public final void finished() {
|
public final void finished() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized boolean hasNext() {
|
public final synchronized boolean hasNext() {
|
||||||
if (batchList.isEmpty()) {
|
if (batchList.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
|
@ -151,11 +155,11 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
return this.iterator.hasNext();
|
return this.iterator.hasNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized MessageReference next() {
|
public final synchronized MessageReference next() {
|
||||||
MessageReference result = null;
|
MessageReference result = null;
|
||||||
if (!this.batchList.isEmpty()&&this.iterator.hasNext()) {
|
if (!this.batchList.isEmpty()&&this.iterator.hasNext()) {
|
||||||
result = this.iterator.next().getValue();
|
result = this.iterator.next();
|
||||||
}
|
}
|
||||||
last = result;
|
last = result;
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
@ -164,7 +168,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized void addMessageLast(MessageReference node) throws Exception {
|
public final synchronized void addMessageLast(MessageReference node) throws Exception {
|
||||||
if (cacheEnabled && hasSpace()) {
|
if (cacheEnabled && hasSpace()) {
|
||||||
recoverMessage(node.getMessage(),true);
|
recoverMessage(node.getMessage(),true);
|
||||||
|
@ -189,13 +193,13 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
protected void setBatch(MessageId messageId) throws Exception {
|
protected void setBatch(MessageId messageId) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized void addMessageFirst(MessageReference node) throws Exception {
|
public final synchronized void addMessageFirst(MessageReference node) throws Exception {
|
||||||
cacheEnabled=false;
|
cacheEnabled=false;
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized void remove() {
|
public final synchronized void remove() {
|
||||||
size--;
|
size--;
|
||||||
if (iterator!=null) {
|
if (iterator!=null) {
|
||||||
|
@ -212,21 +216,22 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized void remove(MessageReference node) {
|
public final synchronized void remove(MessageReference node) {
|
||||||
size--;
|
size--;
|
||||||
cacheEnabled=false;
|
cacheEnabled=false;
|
||||||
batchList.remove(node.getMessageId());
|
batchList.remove(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized void clear() {
|
public final synchronized void clear() {
|
||||||
gc();
|
gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized void gc() {
|
public final synchronized void gc() {
|
||||||
for (Message msg : batchList.values()) {
|
for (Iterator<MessageReference>i = batchList.iterator();i.hasNext();) {
|
||||||
|
MessageReference msg = i.next();
|
||||||
rollback(msg.getMessageId());
|
rollback(msg.getMessageId());
|
||||||
msg.decrementReferenceCount();
|
msg.decrementReferenceCount();
|
||||||
}
|
}
|
||||||
|
@ -241,7 +246,7 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected final synchronized void fillBatch() {
|
protected final synchronized void fillBatch() {
|
||||||
if (batchResetNeeded) {
|
if (batchResetNeeded) {
|
||||||
resetBatch();
|
resetBatch();
|
||||||
|
@ -261,18 +266,18 @@ public abstract class AbstractStoreCursor extends AbstractPendingMessageCursor i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized boolean isEmpty() {
|
public final synchronized boolean isEmpty() {
|
||||||
// negative means more messages added to store through queue.send since last reset
|
// negative means more messages added to store through queue.send since last reset
|
||||||
return size == 0;
|
return size == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized boolean hasMessagesBufferedToDeliver() {
|
public final synchronized boolean hasMessagesBufferedToDeliver() {
|
||||||
return !batchList.isEmpty();
|
return !batchList.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final synchronized int size() {
|
public final synchronized int size() {
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
this.size = getStoreSize();
|
this.size = getStoreSize();
|
||||||
|
|
|
@ -63,9 +63,11 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
|
||||||
/**
|
/**
|
||||||
* @param broker
|
* @param broker
|
||||||
* @param name
|
* @param name
|
||||||
|
* @param prioritizedMessages
|
||||||
* @param store
|
* @param store
|
||||||
*/
|
*/
|
||||||
public FilePendingMessageCursor(Broker broker, String name) {
|
public FilePendingMessageCursor(Broker broker, String name, boolean prioritizedMessages) {
|
||||||
|
super(prioritizedMessages);
|
||||||
this.useCache = false;
|
this.useCache = false;
|
||||||
this.broker = broker;
|
this.broker = broker;
|
||||||
// the store can be null if the BrokerService has persistence
|
// the store can be null if the BrokerService has persistence
|
||||||
|
@ -190,6 +192,7 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
|
||||||
tryAddMessageLast(node, 0);
|
tryAddMessageLast(node, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized boolean tryAddMessageLast(MessageReference node, long maxWaitTime) throws Exception {
|
public synchronized boolean tryAddMessageLast(MessageReference node, long maxWaitTime) throws Exception {
|
||||||
if (!node.isExpired()) {
|
if (!node.isExpired()) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,131 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.activemq.broker.region.cursors;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.apache.activemq.broker.region.MessageReference;
|
||||||
|
import org.apache.activemq.command.MessageId;
|
||||||
|
|
||||||
|
public class OrderedPendingList implements PendingList {
|
||||||
|
PendingNode root = null;
|
||||||
|
PendingNode tail = null;
|
||||||
|
final Map<MessageId, PendingNode> map = new HashMap<MessageId, PendingNode>();
|
||||||
|
|
||||||
|
public PendingNode addMessageFirst(MessageReference message) {
|
||||||
|
PendingNode node = new PendingNode(this, message);
|
||||||
|
if (root == null) {
|
||||||
|
root = node;
|
||||||
|
tail = node;
|
||||||
|
} else {
|
||||||
|
root.linkBefore(node);
|
||||||
|
}
|
||||||
|
this.map.put(message.getMessageId(), node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PendingNode addMessageLast(MessageReference message) {
|
||||||
|
PendingNode node = new PendingNode(this, message);
|
||||||
|
if (root == null) {
|
||||||
|
root = node;
|
||||||
|
} else {
|
||||||
|
tail.linkAfter(node);
|
||||||
|
}
|
||||||
|
tail = node;
|
||||||
|
this.map.put(message.getMessageId(), node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
this.root = null;
|
||||||
|
this.tail = null;
|
||||||
|
this.map.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return this.map.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator<MessageReference> iterator() {
|
||||||
|
return new Iterator<MessageReference>() {
|
||||||
|
private PendingNode current = null;
|
||||||
|
private PendingNode next = root;
|
||||||
|
|
||||||
|
public boolean hasNext() {
|
||||||
|
return next != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageReference next() {
|
||||||
|
MessageReference result = null;
|
||||||
|
this.current = this.next;
|
||||||
|
result = this.current.getMessage();
|
||||||
|
this.next = (PendingNode) this.next.getNext();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
if (this.current != null && this.current.getMessage() != null) {
|
||||||
|
map.remove(this.current.getMessage().getMessageId());
|
||||||
|
}
|
||||||
|
removeNode(this.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(MessageReference message) {
|
||||||
|
if (message != null) {
|
||||||
|
PendingNode node = this.map.remove(message.getMessageId());
|
||||||
|
removeNode(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return this.map.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeNode(PendingNode node) {
|
||||||
|
if (node != null) {
|
||||||
|
map.remove(node.getMessage().getMessageId());
|
||||||
|
if (root == node) {
|
||||||
|
root = (PendingNode) node.getNext();
|
||||||
|
}
|
||||||
|
if (tail == node) {
|
||||||
|
tail = (PendingNode) node.getPrevious();
|
||||||
|
}
|
||||||
|
node.unlink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PendingNode> getAsList() {
|
||||||
|
List<PendingNode> result = new ArrayList<PendingNode>(size());
|
||||||
|
PendingNode node = root;
|
||||||
|
while (node != null) {
|
||||||
|
result.add(node);
|
||||||
|
node = (PendingNode) node.getNext();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "OrderedPendingList(" + System.identityHashCode(this) + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.activemq.broker.region.cursors;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import org.apache.activemq.broker.region.MessageReference;
|
||||||
|
|
||||||
|
public interface PendingList {
|
||||||
|
|
||||||
|
public boolean isEmpty();
|
||||||
|
public void clear();
|
||||||
|
public PendingNode addMessageFirst(MessageReference message);
|
||||||
|
public PendingNode addMessageLast(MessageReference message);
|
||||||
|
public void remove(MessageReference message);
|
||||||
|
public int size();
|
||||||
|
public Iterator<MessageReference> iterator();
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.activemq.broker.region.cursors;
|
||||||
|
|
||||||
|
import org.apache.activemq.broker.region.MessageReference;
|
||||||
|
import org.apache.activemq.util.LinkedNode;
|
||||||
|
|
||||||
|
public class PendingNode extends LinkedNode {
|
||||||
|
private final MessageReference message;
|
||||||
|
private final OrderedPendingList list;
|
||||||
|
public PendingNode(OrderedPendingList list,MessageReference message) {
|
||||||
|
this.list = list;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageReference getMessage() {
|
||||||
|
return this.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderedPendingList getList() {
|
||||||
|
return this.list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
PendingNode n = (PendingNode) getNext();
|
||||||
|
String str = "PendingNode(";
|
||||||
|
str += System.identityHashCode(this) + "),root="+isHeadNode()+",next="+(n != null ?System.identityHashCode(n):"NULL");
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.activemq.broker.region.cursors;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.apache.activemq.broker.region.MessageReference;
|
||||||
|
import org.apache.activemq.command.MessageId;
|
||||||
|
|
||||||
|
public class PrioritizedPendingList implements PendingList {
|
||||||
|
static final Integer MAX_PRIORITY = 10;
|
||||||
|
private final OrderedPendingList[] lists = new OrderedPendingList[MAX_PRIORITY];
|
||||||
|
final Map<MessageId, PendingNode> map = new HashMap<MessageId, PendingNode>();
|
||||||
|
|
||||||
|
public PrioritizedPendingList() {
|
||||||
|
for (int i = 0; i < MAX_PRIORITY; i++) {
|
||||||
|
this.lists[i] = new OrderedPendingList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public PendingNode addMessageFirst(MessageReference message) {
|
||||||
|
PendingNode node = getList(message).addMessageFirst(message);
|
||||||
|
this.map.put(message.getMessageId(), node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PendingNode addMessageLast(MessageReference message) {
|
||||||
|
PendingNode node = getList(message).addMessageLast(message);
|
||||||
|
this.map.put(message.getMessageId(), node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
for (int i = 0; i < MAX_PRIORITY; i++) {
|
||||||
|
this.lists[i].clear();
|
||||||
|
}
|
||||||
|
this.map.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return this.map.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator<MessageReference> iterator() {
|
||||||
|
return new PrioritizedPendingListIterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(MessageReference message) {
|
||||||
|
if (message != null) {
|
||||||
|
PendingNode node = this.map.remove(message.getMessageId());
|
||||||
|
if (node != null) {
|
||||||
|
node.getList().removeNode(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return this.map.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "PrioritizedPendingList(" + System.identityHashCode(this) + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getPriority(MessageReference message) {
|
||||||
|
int priority = javax.jms.Message.DEFAULT_PRIORITY;
|
||||||
|
if (message.getMessageId() != null) {
|
||||||
|
Math.max(message.getMessage().getPriority(), 0);
|
||||||
|
priority = Math.min(priority, 9);
|
||||||
|
}
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected OrderedPendingList getList(MessageReference msg) {
|
||||||
|
return lists[getPriority(msg)];
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PrioritizedPendingListIterator implements Iterator<MessageReference> {
|
||||||
|
private int index = 0;
|
||||||
|
private int currentIndex = 0;
|
||||||
|
List<PendingNode> list = new ArrayList<PendingNode>(size());
|
||||||
|
|
||||||
|
PrioritizedPendingListIterator() {
|
||||||
|
for (int i = MAX_PRIORITY - 1; i >= 0; i--) {
|
||||||
|
OrderedPendingList orderedPendingList = lists[i];
|
||||||
|
if (!orderedPendingList.isEmpty()) {
|
||||||
|
list.addAll(orderedPendingList.getAsList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public boolean hasNext() {
|
||||||
|
return list.size() > index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageReference next() {
|
||||||
|
PendingNode node = list.get(this.index);
|
||||||
|
this.currentIndex = this.index;
|
||||||
|
this.index++;
|
||||||
|
return node.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
PendingNode node = list.get(this.currentIndex);
|
||||||
|
if (node != null) {
|
||||||
|
map.remove(node.getMessage().getMessageId());
|
||||||
|
node.getList().removeNode(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -21,7 +21,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import org.apache.activemq.advisory.AdvisorySupport;
|
import org.apache.activemq.advisory.AdvisorySupport;
|
||||||
import org.apache.activemq.broker.Broker;
|
import org.apache.activemq.broker.Broker;
|
||||||
import org.apache.activemq.broker.ConnectionContext;
|
import org.apache.activemq.broker.ConnectionContext;
|
||||||
|
@ -58,13 +57,14 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
* @param subscription subscription for this cursor
|
* @param subscription subscription for this cursor
|
||||||
*/
|
*/
|
||||||
public StoreDurableSubscriberCursor(Broker broker,String clientId, String subscriberName,int maxBatchSize, Subscription subscription) {
|
public StoreDurableSubscriberCursor(Broker broker,String clientId, String subscriberName,int maxBatchSize, Subscription subscription) {
|
||||||
|
super(AbstractPendingMessageCursor.isPrioritizedMessageSubscriber(broker,subscription));
|
||||||
this.subscription=subscription;
|
this.subscription=subscription;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.subscriberName = subscriberName;
|
this.subscriberName = subscriberName;
|
||||||
if (broker.getBrokerService().isPersistent()) {
|
if (broker.getBrokerService().isPersistent()) {
|
||||||
this.nonPersistent = new FilePendingMessageCursor(broker,clientId + subscriberName);
|
this.nonPersistent = new FilePendingMessageCursor(broker,clientId + subscriberName,this.prioritizedMessages);
|
||||||
}else {
|
}else {
|
||||||
this.nonPersistent = new VMPendingMessageCursor();
|
this.nonPersistent = new VMPendingMessageCursor(this.prioritizedMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nonPersistent.setMaxBatchSize(maxBatchSize);
|
this.nonPersistent.setMaxBatchSize(maxBatchSize);
|
||||||
|
@ -72,6 +72,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
this.storePrefetches.add(this.nonPersistent);
|
this.storePrefetches.add(this.nonPersistent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void start() throws Exception {
|
public synchronized void start() throws Exception {
|
||||||
if (!isStarted()) {
|
if (!isStarted()) {
|
||||||
super.start();
|
super.start();
|
||||||
|
@ -82,6 +83,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void stop() throws Exception {
|
public synchronized void stop() throws Exception {
|
||||||
if (isStarted()) {
|
if (isStarted()) {
|
||||||
super.stop();
|
super.stop();
|
||||||
|
@ -98,6 +100,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
* @param destination
|
* @param destination
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void add(ConnectionContext context, Destination destination) throws Exception {
|
public synchronized void add(ConnectionContext context, Destination destination) throws Exception {
|
||||||
if (destination != null && !AdvisorySupport.isAdvisoryTopic(destination.getActiveMQDestination())) {
|
if (destination != null && !AdvisorySupport.isAdvisoryTopic(destination.getActiveMQDestination())) {
|
||||||
TopicStorePrefetch tsp = new TopicStorePrefetch(this.subscription,(Topic)destination, clientId, subscriberName);
|
TopicStorePrefetch tsp = new TopicStorePrefetch(this.subscription,(Topic)destination, clientId, subscriberName);
|
||||||
|
@ -122,6 +125,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
* @param destination
|
* @param destination
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized List<MessageReference> remove(ConnectionContext context, Destination destination) throws Exception {
|
public synchronized List<MessageReference> remove(ConnectionContext context, Destination destination) throws Exception {
|
||||||
PendingMessageCursor tsp = topics.remove(destination);
|
PendingMessageCursor tsp = topics.remove(destination);
|
||||||
if (tsp != null) {
|
if (tsp != null) {
|
||||||
|
@ -133,6 +137,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
/**
|
/**
|
||||||
* @return true if there are no pending messages
|
* @return true if there are no pending messages
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized boolean isEmpty() {
|
public synchronized boolean isEmpty() {
|
||||||
for (PendingMessageCursor tsp : storePrefetches) {
|
for (PendingMessageCursor tsp : storePrefetches) {
|
||||||
if( !tsp.isEmpty() )
|
if( !tsp.isEmpty() )
|
||||||
|
@ -141,6 +146,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized boolean isEmpty(Destination destination) {
|
public synchronized boolean isEmpty(Destination destination) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
TopicStorePrefetch tsp = topics.get(destination);
|
TopicStorePrefetch tsp = topics.get(destination);
|
||||||
|
@ -157,10 +163,12 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
* @see org.apache.activemq.broker.region.cursors.AbstractPendingMessageCursor
|
* @see org.apache.activemq.broker.region.cursors.AbstractPendingMessageCursor
|
||||||
* @return true if recovery required
|
* @return true if recovery required
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isRecoveryRequired() {
|
public boolean isRecoveryRequired() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void addMessageLast(MessageReference node) throws Exception {
|
public synchronized void addMessageLast(MessageReference node) throws Exception {
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
Message msg = node.getMessage();
|
Message msg = node.getMessage();
|
||||||
|
@ -179,16 +187,19 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void addRecoveredMessage(MessageReference node) throws Exception {
|
public synchronized void addRecoveredMessage(MessageReference node) throws Exception {
|
||||||
nonPersistent.addMessageLast(node);
|
nonPersistent.addMessageLast(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void clear() {
|
public synchronized void clear() {
|
||||||
for (PendingMessageCursor tsp : storePrefetches) {
|
for (PendingMessageCursor tsp : storePrefetches) {
|
||||||
tsp.clear();
|
tsp.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized boolean hasNext() {
|
public synchronized boolean hasNext() {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -203,35 +214,41 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized MessageReference next() {
|
public synchronized MessageReference next() {
|
||||||
MessageReference result = currentCursor != null ? currentCursor.next() : null;
|
MessageReference result = currentCursor != null ? currentCursor.next() : null;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void remove() {
|
public synchronized void remove() {
|
||||||
if (currentCursor != null) {
|
if (currentCursor != null) {
|
||||||
currentCursor.remove();
|
currentCursor.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void remove(MessageReference node) {
|
public synchronized void remove(MessageReference node) {
|
||||||
if (currentCursor != null) {
|
if (currentCursor != null) {
|
||||||
currentCursor.remove(node);
|
currentCursor.remove(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void reset() {
|
public synchronized void reset() {
|
||||||
for (PendingMessageCursor storePrefetch : storePrefetches) {
|
for (PendingMessageCursor storePrefetch : storePrefetches) {
|
||||||
storePrefetch.reset();
|
storePrefetch.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void release() {
|
public synchronized void release() {
|
||||||
for (PendingMessageCursor storePrefetch : storePrefetches) {
|
for (PendingMessageCursor storePrefetch : storePrefetches) {
|
||||||
storePrefetch.release();
|
storePrefetch.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized int size() {
|
public synchronized int size() {
|
||||||
int pendingCount=0;
|
int pendingCount=0;
|
||||||
for (PendingMessageCursor tsp : storePrefetches) {
|
for (PendingMessageCursor tsp : storePrefetches) {
|
||||||
|
@ -240,6 +257,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
return pendingCount;
|
return pendingCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMaxBatchSize(int maxBatchSize) {
|
public void setMaxBatchSize(int maxBatchSize) {
|
||||||
for (PendingMessageCursor storePrefetch : storePrefetches) {
|
for (PendingMessageCursor storePrefetch : storePrefetches) {
|
||||||
storePrefetch.setMaxBatchSize(maxBatchSize);
|
storePrefetch.setMaxBatchSize(maxBatchSize);
|
||||||
|
@ -247,12 +265,14 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
super.setMaxBatchSize(maxBatchSize);
|
super.setMaxBatchSize(maxBatchSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void gc() {
|
public synchronized void gc() {
|
||||||
for (PendingMessageCursor tsp : storePrefetches) {
|
for (PendingMessageCursor tsp : storePrefetches) {
|
||||||
tsp.gc();
|
tsp.gc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setSystemUsage(SystemUsage usageManager) {
|
public void setSystemUsage(SystemUsage usageManager) {
|
||||||
super.setSystemUsage(usageManager);
|
super.setSystemUsage(usageManager);
|
||||||
for (PendingMessageCursor tsp : storePrefetches) {
|
for (PendingMessageCursor tsp : storePrefetches) {
|
||||||
|
@ -260,6 +280,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark) {
|
public void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark) {
|
||||||
super.setMemoryUsageHighWaterMark(memoryUsageHighWaterMark);
|
super.setMemoryUsageHighWaterMark(memoryUsageHighWaterMark);
|
||||||
for (PendingMessageCursor cursor : storePrefetches) {
|
for (PendingMessageCursor cursor : storePrefetches) {
|
||||||
|
@ -267,6 +288,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMaxProducersToAudit(int maxProducersToAudit) {
|
public void setMaxProducersToAudit(int maxProducersToAudit) {
|
||||||
super.setMaxProducersToAudit(maxProducersToAudit);
|
super.setMaxProducersToAudit(maxProducersToAudit);
|
||||||
for (PendingMessageCursor cursor : storePrefetches) {
|
for (PendingMessageCursor cursor : storePrefetches) {
|
||||||
|
@ -274,6 +296,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMaxAuditDepth(int maxAuditDepth) {
|
public void setMaxAuditDepth(int maxAuditDepth) {
|
||||||
super.setMaxAuditDepth(maxAuditDepth);
|
super.setMaxAuditDepth(maxAuditDepth);
|
||||||
for (PendingMessageCursor cursor : storePrefetches) {
|
for (PendingMessageCursor cursor : storePrefetches) {
|
||||||
|
@ -281,6 +304,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setEnableAudit(boolean enableAudit) {
|
public void setEnableAudit(boolean enableAudit) {
|
||||||
super.setEnableAudit(enableAudit);
|
super.setEnableAudit(enableAudit);
|
||||||
for (PendingMessageCursor cursor : storePrefetches) {
|
for (PendingMessageCursor cursor : storePrefetches) {
|
||||||
|
@ -288,6 +312,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setUseCache(boolean useCache) {
|
public void setUseCache(boolean useCache) {
|
||||||
super.setUseCache(useCache);
|
super.setUseCache(useCache);
|
||||||
for (PendingMessageCursor cursor : storePrefetches) {
|
for (PendingMessageCursor cursor : storePrefetches) {
|
||||||
|
@ -313,6 +338,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
||||||
return currentCursor;
|
return currentCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "StoreDurableSubscriber(" + clientId + ":" + subscriberName + ")";
|
return "StoreDurableSubscriber(" + clientId + ":" + subscriberName + ")";
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,21 +32,21 @@ import org.apache.commons.logging.LogFactory;
|
||||||
public class StoreQueueCursor extends AbstractPendingMessageCursor {
|
public class StoreQueueCursor extends AbstractPendingMessageCursor {
|
||||||
|
|
||||||
private static final Log LOG = LogFactory.getLog(StoreQueueCursor.class);
|
private static final Log LOG = LogFactory.getLog(StoreQueueCursor.class);
|
||||||
private Broker broker;
|
private final Broker broker;
|
||||||
private int pendingCount;
|
private int pendingCount;
|
||||||
private Queue queue;
|
private final Queue queue;
|
||||||
private PendingMessageCursor nonPersistent;
|
private PendingMessageCursor nonPersistent;
|
||||||
private QueueStorePrefetch persistent;
|
private final QueueStorePrefetch persistent;
|
||||||
private boolean started;
|
private boolean started;
|
||||||
private PendingMessageCursor currentCursor;
|
private PendingMessageCursor currentCursor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct
|
* Construct
|
||||||
*
|
* @param broker
|
||||||
* @param queue
|
* @param queue
|
||||||
* @param tmpStore
|
|
||||||
*/
|
*/
|
||||||
public StoreQueueCursor(Broker broker,Queue queue) {
|
public StoreQueueCursor(Broker broker,Queue queue) {
|
||||||
|
super((queue != null ? queue.isPrioritizedMessages():false));
|
||||||
this.broker=broker;
|
this.broker=broker;
|
||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
this.persistent = new QueueStorePrefetch(queue);
|
this.persistent = new QueueStorePrefetch(queue);
|
||||||
|
@ -58,9 +58,9 @@ public class StoreQueueCursor extends AbstractPendingMessageCursor {
|
||||||
super.start();
|
super.start();
|
||||||
if (nonPersistent == null) {
|
if (nonPersistent == null) {
|
||||||
if (broker.getBrokerService().isPersistent()) {
|
if (broker.getBrokerService().isPersistent()) {
|
||||||
nonPersistent = new FilePendingMessageCursor(broker,queue.getName());
|
nonPersistent = new FilePendingMessageCursor(broker,queue.getName(),this.prioritizedMessages);
|
||||||
}else {
|
}else {
|
||||||
nonPersistent = new VMPendingMessageCursor();
|
nonPersistent = new VMPendingMessageCursor(this.prioritizedMessages);
|
||||||
}
|
}
|
||||||
nonPersistent.setMaxBatchSize(getMaxBatchSize());
|
nonPersistent.setMaxBatchSize(getMaxBatchSize());
|
||||||
nonPersistent.setSystemUsage(systemUsage);
|
nonPersistent.setSystemUsage(systemUsage);
|
||||||
|
@ -101,7 +101,7 @@ public class StoreQueueCursor extends AbstractPendingMessageCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addMessageFirst(MessageReference node) throws Exception {
|
public synchronized void addMessageFirst(MessageReference node) throws Exception {
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
Message msg = node.getMessage();
|
Message msg = node.getMessage();
|
||||||
|
@ -240,6 +240,7 @@ public class StoreQueueCursor extends AbstractPendingMessageCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setUseCache(boolean useCache) {
|
public void setUseCache(boolean useCache) {
|
||||||
super.setUseCache(useCache);
|
super.setUseCache(useCache);
|
||||||
if (persistent != null) {
|
if (persistent != null) {
|
||||||
|
@ -250,6 +251,7 @@ public class StoreQueueCursor extends AbstractPendingMessageCursor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark) {
|
public void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark) {
|
||||||
super.setMemoryUsageHighWaterMark(memoryUsageHighWaterMark);
|
super.setMemoryUsageHighWaterMark(memoryUsageHighWaterMark);
|
||||||
if (persistent != null) {
|
if (persistent != null) {
|
||||||
|
|
|
@ -32,13 +32,20 @@ import org.apache.activemq.broker.region.QueueMessageReference;
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
private final LinkedList<MessageReference> list = new LinkedList<MessageReference>();
|
private final PendingList list;
|
||||||
private Iterator<MessageReference> iter;
|
private Iterator<MessageReference> iter;
|
||||||
public VMPendingMessageCursor() {
|
|
||||||
|
public VMPendingMessageCursor(boolean prioritizedMessages) {
|
||||||
|
super(prioritizedMessages);
|
||||||
this.useCache = false;
|
this.useCache = false;
|
||||||
|
if (this.prioritizedMessages) {
|
||||||
|
this.list= new PrioritizedPendingList();
|
||||||
|
}else {
|
||||||
|
this.list = new OrderedPendingList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized List<MessageReference> remove(ConnectionContext context, Destination destination)
|
public synchronized List<MessageReference> remove(ConnectionContext context, Destination destination)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
List<MessageReference> rc = new ArrayList<MessageReference>();
|
List<MessageReference> rc = new ArrayList<MessageReference>();
|
||||||
|
@ -56,7 +63,7 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
/**
|
/**
|
||||||
* @return true if there are no pending messages
|
* @return true if there are no pending messages
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public synchronized boolean isEmpty() {
|
public synchronized boolean isEmpty() {
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -79,9 +86,9 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
/**
|
/**
|
||||||
* reset the cursor
|
* reset the cursor
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public synchronized void reset() {
|
public synchronized void reset() {
|
||||||
iter = list.listIterator();
|
iter = list.iterator();
|
||||||
last = null;
|
last = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,10 +97,10 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public synchronized void addMessageLast(MessageReference node) {
|
public synchronized void addMessageLast(MessageReference node) {
|
||||||
node.incrementReferenceCount();
|
node.incrementReferenceCount();
|
||||||
list.addLast(node);
|
list.addMessageLast(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,16 +109,16 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
* @param position
|
* @param position
|
||||||
* @param node
|
* @param node
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public synchronized void addMessageFirst(MessageReference node) {
|
public synchronized void addMessageFirst(MessageReference node) {
|
||||||
node.incrementReferenceCount();
|
node.incrementReferenceCount();
|
||||||
list.addFirst(node);
|
list.addMessageFirst(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if there pending messages to dispatch
|
* @return true if there pending messages to dispatch
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public synchronized boolean hasNext() {
|
public synchronized boolean hasNext() {
|
||||||
return iter.hasNext();
|
return iter.hasNext();
|
||||||
}
|
}
|
||||||
|
@ -119,7 +126,7 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
/**
|
/**
|
||||||
* @return the next pending message
|
* @return the next pending message
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public synchronized MessageReference next() {
|
public synchronized MessageReference next() {
|
||||||
last = iter.next();
|
last = iter.next();
|
||||||
if (last != null) {
|
if (last != null) {
|
||||||
|
@ -131,7 +138,7 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
/**
|
/**
|
||||||
* remove the message at the cursor position
|
* remove the message at the cursor position
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public synchronized void remove() {
|
public synchronized void remove() {
|
||||||
if (last != null) {
|
if (last != null) {
|
||||||
last.decrementReferenceCount();
|
last.decrementReferenceCount();
|
||||||
|
@ -142,7 +149,7 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
/**
|
/**
|
||||||
* @return the number of pending messages
|
* @return the number of pending messages
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public synchronized int size() {
|
public synchronized int size() {
|
||||||
return list.size();
|
return list.size();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +157,7 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
/**
|
/**
|
||||||
* clear all pending messages
|
* clear all pending messages
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public synchronized void clear() {
|
public synchronized void clear() {
|
||||||
for (Iterator<MessageReference> i = list.iterator(); i.hasNext();) {
|
for (Iterator<MessageReference> i = list.iterator(); i.hasNext();) {
|
||||||
MessageReference ref = i.next();
|
MessageReference ref = i.next();
|
||||||
|
@ -159,16 +166,10 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
list.clear();
|
list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void remove(MessageReference node) {
|
public synchronized void remove(MessageReference node) {
|
||||||
for (Iterator<MessageReference> i = list.iterator(); i.hasNext();) {
|
list.remove(node);
|
||||||
MessageReference ref = i.next();
|
node.decrementReferenceCount();
|
||||||
if (node.getMessageId().equals(ref.getMessageId())) {
|
|
||||||
ref.decrementReferenceCount();
|
|
||||||
i.remove();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,10 +178,11 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
* @param maxItems
|
* @param maxItems
|
||||||
* @return a list of paged in messages
|
* @return a list of paged in messages
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public LinkedList<MessageReference> pageInList(int maxItems) {
|
public LinkedList<MessageReference> pageInList(int maxItems) {
|
||||||
LinkedList<MessageReference> result = new LinkedList<MessageReference>();
|
LinkedList<MessageReference> result = new LinkedList<MessageReference>();
|
||||||
for (MessageReference ref: list) {
|
for (Iterator<MessageReference>i = list.iterator();i.hasNext();) {
|
||||||
|
MessageReference ref = i.next();
|
||||||
ref.incrementReferenceCount();
|
ref.incrementReferenceCount();
|
||||||
result.add(ref);
|
result.add(ref);
|
||||||
if (result.size() >= maxItems) {
|
if (result.size() >= maxItems) {
|
||||||
|
@ -190,12 +192,12 @@ public class VMPendingMessageCursor extends AbstractPendingMessageCursor {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTransient() {
|
public boolean isTransient() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroy() throws Exception {
|
public void destroy() throws Exception {
|
||||||
super.destroy();
|
super.destroy();
|
||||||
clear();
|
clear();
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.activemq.broker.region.policy;
|
||||||
|
|
||||||
import org.apache.activemq.broker.Broker;
|
import org.apache.activemq.broker.Broker;
|
||||||
import org.apache.activemq.broker.region.Subscription;
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
|
import org.apache.activemq.broker.region.cursors.AbstractPendingMessageCursor;
|
||||||
import org.apache.activemq.broker.region.cursors.FilePendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.FilePendingMessageCursor;
|
||||||
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
|
|
||||||
|
@ -42,6 +43,6 @@ public class FilePendingDurableSubscriberMessageStoragePolicy implements Pending
|
||||||
* @return the Pending Message cursor
|
* @return the Pending Message cursor
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String clientId, String name, int maxBatchSize, Subscription sub) {
|
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String clientId, String name, int maxBatchSize, Subscription sub) {
|
||||||
return new FilePendingMessageCursor(broker,name);
|
return new FilePendingMessageCursor(broker,name,AbstractPendingMessageCursor.isPrioritizedMessageSubscriber(broker, sub));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class FilePendingQueueMessageStoragePolicy implements PendingQueueMessage
|
||||||
* org.apache.activemq.kaha.Store)
|
* org.apache.activemq.kaha.Store)
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getQueuePendingMessageCursor(Broker broker,Queue queue) {
|
public PendingMessageCursor getQueuePendingMessageCursor(Broker broker,Queue queue) {
|
||||||
return new FilePendingMessageCursor(broker,"PendingCursor:" + queue.getName());
|
return new FilePendingMessageCursor(broker,"PendingCursor:" + queue.getName(),queue.isPrioritizedMessages());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
package org.apache.activemq.broker.region.policy;
|
package org.apache.activemq.broker.region.policy;
|
||||||
|
|
||||||
import org.apache.activemq.broker.Broker;
|
import org.apache.activemq.broker.Broker;
|
||||||
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
|
import org.apache.activemq.broker.region.cursors.AbstractPendingMessageCursor;
|
||||||
import org.apache.activemq.broker.region.cursors.FilePendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.FilePendingMessageCursor;
|
||||||
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
|
|
||||||
|
@ -31,14 +33,16 @@ import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
public class FilePendingSubscriberMessageStoragePolicy implements PendingSubscriberMessageStoragePolicy {
|
public class FilePendingSubscriberMessageStoragePolicy implements PendingSubscriberMessageStoragePolicy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param broker
|
* @param broker
|
||||||
* @param name
|
* @param name
|
||||||
* @param maxBatchSize
|
* @param maxBatchSize
|
||||||
* @return a Cursor
|
* @return a Cursor
|
||||||
* @see org.apache.activemq.broker.region.policy.PendingSubscriberMessageStoragePolicy#getSubscriberPendingMessageCursor(java.lang.String,
|
* @see org.apache.activemq.broker.region.policy.PendingSubscriberMessageStoragePolicy#getSubscriberPendingMessageCursor(java.lang.String,
|
||||||
* org.apache.activemq.kaha.Store, int)
|
* org.apache.activemq.kaha.Store, int)
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String name,int maxBatchSize) {
|
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker, String name, int maxBatchSize,
|
||||||
return new FilePendingMessageCursor(broker,"PendingCursor:" + name);
|
Subscription subs) {
|
||||||
|
return new FilePendingMessageCursor(broker, "PendingCursor:" + name, AbstractPendingMessageCursor
|
||||||
|
.isPrioritizedMessageSubscriber(broker, subs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.apache.activemq.broker.region.policy;
|
package org.apache.activemq.broker.region.policy;
|
||||||
|
|
||||||
import org.apache.activemq.broker.Broker;
|
import org.apache.activemq.broker.Broker;
|
||||||
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,5 +36,5 @@ public interface PendingSubscriberMessageStoragePolicy {
|
||||||
* @param maxBatchSize
|
* @param maxBatchSize
|
||||||
* @return the Pending Message cursor
|
* @return the Pending Message cursor
|
||||||
*/
|
*/
|
||||||
PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String name,int maxBatchSize);
|
PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String name,int maxBatchSize,Subscription subs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,7 @@ public class PolicyEntry extends DestinationMapEntry {
|
||||||
private int cursorMemoryHighWaterMark = 70;
|
private int cursorMemoryHighWaterMark = 70;
|
||||||
private int storeUsageHighWaterMark = 100;
|
private int storeUsageHighWaterMark = 100;
|
||||||
private SlowConsumerStrategy slowConsumerStrategy;
|
private SlowConsumerStrategy slowConsumerStrategy;
|
||||||
|
private boolean prioritizedMessages;
|
||||||
|
|
||||||
|
|
||||||
public void configure(Broker broker,Queue queue) {
|
public void configure(Broker broker,Queue queue) {
|
||||||
|
@ -155,6 +156,7 @@ public class PolicyEntry extends DestinationMapEntry {
|
||||||
scs.setScheduler(broker.getScheduler());
|
scs.setScheduler(broker.getScheduler());
|
||||||
}
|
}
|
||||||
destination.setSlowConsumerStrategy(scs);
|
destination.setSlowConsumerStrategy(scs);
|
||||||
|
destination.setPrioritizedMessages(isPrioritizedMessages());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configure(Broker broker, SystemUsage memoryManager, TopicSubscription subscription) {
|
public void configure(Broker broker, SystemUsage memoryManager, TopicSubscription subscription) {
|
||||||
|
@ -184,7 +186,7 @@ public class PolicyEntry extends DestinationMapEntry {
|
||||||
if (pendingSubscriberPolicy != null) {
|
if (pendingSubscriberPolicy != null) {
|
||||||
String name = subscription.getContext().getClientId() + "_" + subscription.getConsumerInfo().getConsumerId();
|
String name = subscription.getContext().getClientId() + "_" + subscription.getConsumerInfo().getConsumerId();
|
||||||
int maxBatchSize = subscription.getConsumerInfo().getPrefetchSize();
|
int maxBatchSize = subscription.getConsumerInfo().getPrefetchSize();
|
||||||
subscription.setMatched(pendingSubscriberPolicy.getSubscriberPendingMessageCursor(broker,name, maxBatchSize));
|
subscription.setMatched(pendingSubscriberPolicy.getSubscriberPendingMessageCursor(broker,name, maxBatchSize,subscription));
|
||||||
}
|
}
|
||||||
if (enableAudit) {
|
if (enableAudit) {
|
||||||
subscription.setEnableAudit(enableAudit);
|
subscription.setEnableAudit(enableAudit);
|
||||||
|
@ -739,5 +741,14 @@ public class PolicyEntry extends DestinationMapEntry {
|
||||||
public SlowConsumerStrategy getSlowConsumerStrategy() {
|
public SlowConsumerStrategy getSlowConsumerStrategy() {
|
||||||
return this.slowConsumerStrategy;
|
return this.slowConsumerStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isPrioritizedMessages() {
|
||||||
|
return this.prioritizedMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrioritizedMessages(boolean prioritizedMessages) {
|
||||||
|
this.prioritizedMessages = prioritizedMessages;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.activemq.broker.region.policy;
|
||||||
|
|
||||||
import org.apache.activemq.broker.Broker;
|
import org.apache.activemq.broker.Broker;
|
||||||
import org.apache.activemq.broker.region.Subscription;
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
|
import org.apache.activemq.broker.region.cursors.AbstractPendingMessageCursor;
|
||||||
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
import org.apache.activemq.broker.region.cursors.VMPendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.VMPendingMessageCursor;
|
||||||
|
|
||||||
|
@ -40,6 +41,6 @@ public class VMPendingDurableSubscriberMessageStoragePolicy implements PendingDu
|
||||||
* @return the Pending Message cursor
|
* @return the Pending Message cursor
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String clientId, String name,int maxBatchSize, Subscription sub) {
|
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String clientId, String name,int maxBatchSize, Subscription sub) {
|
||||||
return new VMPendingMessageCursor();
|
return new VMPendingMessageCursor(AbstractPendingMessageCursor.isPrioritizedMessageSubscriber(broker, sub));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,6 @@ public class VMPendingQueueMessageStoragePolicy implements PendingQueueMessageSt
|
||||||
* @return the cursor
|
* @return the cursor
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getQueuePendingMessageCursor(Broker broker,Queue queue) {
|
public PendingMessageCursor getQueuePendingMessageCursor(Broker broker,Queue queue) {
|
||||||
return new VMPendingMessageCursor();
|
return new VMPendingMessageCursor(queue.isPrioritizedMessages());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
package org.apache.activemq.broker.region.policy;
|
package org.apache.activemq.broker.region.policy;
|
||||||
|
|
||||||
import org.apache.activemq.broker.Broker;
|
import org.apache.activemq.broker.Broker;
|
||||||
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
|
import org.apache.activemq.broker.region.cursors.AbstractPendingMessageCursor;
|
||||||
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
import org.apache.activemq.broker.region.cursors.VMPendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.VMPendingMessageCursor;
|
||||||
|
|
||||||
|
@ -38,7 +40,7 @@ public class VMPendingSubscriberMessageStoragePolicy implements PendingSubscribe
|
||||||
* @see org.apache.activemq.broker.region.policy.PendingSubscriberMessageStoragePolicy#getSubscriberPendingMessageCursor(java.lang.String,
|
* @see org.apache.activemq.broker.region.policy.PendingSubscriberMessageStoragePolicy#getSubscriberPendingMessageCursor(java.lang.String,
|
||||||
* org.apache.activemq.kaha.Store, int)
|
* org.apache.activemq.kaha.Store, int)
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String name,int maxBatchSize) {
|
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String name,int maxBatchSize,Subscription subs) {
|
||||||
return new VMPendingMessageCursor();
|
return new VMPendingMessageCursor(AbstractPendingMessageCursor.isPrioritizedMessageSubscriber(broker, subs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.broker.util;
|
package org.apache.activemq.broker.util;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import org.apache.activemq.broker.BrokerPluginSupport;
|
import org.apache.activemq.broker.BrokerPluginSupport;
|
||||||
|
@ -65,7 +64,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
private boolean logInternalEvents = false;
|
private boolean logInternalEvents = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @org.apache.xbean.InitMethod
|
* @org.apache.xbean.InitMethod
|
||||||
*/
|
*/
|
||||||
|
@ -77,7 +76,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
public boolean isLogAll() {
|
public boolean isLogAll() {
|
||||||
return logAll;
|
return logAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log all Events that go through the Plugin
|
* Log all Events that go through the Plugin
|
||||||
*/
|
*/
|
||||||
|
@ -152,15 +151,12 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void acknowledge(ConsumerBrokerExchange consumerExchange,
|
public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception {
|
||||||
MessageAck ack) throws Exception {
|
|
||||||
if (isLogAll() || isLogConsumerEvents()) {
|
if (isLogAll() || isLogConsumerEvents()) {
|
||||||
LOG.info("Acknowledging message for client ID : "
|
LOG.info("Acknowledging message for client ID : " + consumerExchange.getConnectionContext().getClientId()
|
||||||
+ consumerExchange.getConnectionContext().getClientId()
|
|
||||||
+ (ack.getMessageCount() == 1 ? ", " + ack.getLastMessageId() : ""));
|
+ (ack.getMessageCount() == 1 ? ", " + ack.getLastMessageId() : ""));
|
||||||
if (LOG.isTraceEnabled() && ack.getMessageCount() > 1) {
|
if (LOG.isTraceEnabled() && ack.getMessageCount() > 1) {
|
||||||
LOG.trace("Message count: " + ack.getMessageCount()
|
LOG.trace("Message count: " + ack.getMessageCount() + ", First Message Id: " + ack.getFirstMessageId()
|
||||||
+ ", First Message Id: " + ack.getFirstMessageId()
|
|
||||||
+ ", Last Message Id: " + ack.getLastMessageId());
|
+ ", Last Message Id: " + ack.getLastMessageId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,18 +164,15 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response messagePull(ConnectionContext context, MessagePull pull)
|
public Response messagePull(ConnectionContext context, MessagePull pull) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogConsumerEvents()) {
|
if (isLogAll() || isLogConsumerEvents()) {
|
||||||
LOG.info("Message Pull from : " + context.getClientId() + " on "
|
LOG.info("Message Pull from : " + context.getClientId() + " on " + pull.getDestination().getPhysicalName());
|
||||||
+ pull.getDestination().getPhysicalName());
|
|
||||||
}
|
}
|
||||||
return super.messagePull(context, pull);
|
return super.messagePull(context, pull);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConnection(ConnectionContext context, ConnectionInfo info)
|
public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogConnectionEvents()) {
|
if (isLogAll() || isLogConnectionEvents()) {
|
||||||
LOG.info("Adding Connection : " + context);
|
LOG.info("Adding Connection : " + context);
|
||||||
}
|
}
|
||||||
|
@ -187,8 +180,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info)
|
public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogConsumerEvents()) {
|
if (isLogAll() || isLogConsumerEvents()) {
|
||||||
LOG.info("Adding Consumer : " + info);
|
LOG.info("Adding Consumer : " + info);
|
||||||
}
|
}
|
||||||
|
@ -196,8 +188,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addProducer(ConnectionContext context, ProducerInfo info)
|
public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogProducerEvents()) {
|
if (isLogAll() || isLogProducerEvents()) {
|
||||||
LOG.info("Adding Producer :" + info);
|
LOG.info("Adding Producer :" + info);
|
||||||
}
|
}
|
||||||
|
@ -205,8 +196,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void commitTransaction(ConnectionContext context, TransactionId xid,
|
public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase) throws Exception {
|
||||||
boolean onePhase) throws Exception {
|
|
||||||
if (isLogAll() || isLogTransactionEvents()) {
|
if (isLogAll() || isLogTransactionEvents()) {
|
||||||
LOG.info("Commiting transaction : " + xid.getTransactionKey());
|
LOG.info("Commiting transaction : " + xid.getTransactionKey());
|
||||||
}
|
}
|
||||||
|
@ -214,8 +204,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeSubscription(ConnectionContext context,
|
public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception {
|
||||||
RemoveSubscriptionInfo info) throws Exception {
|
|
||||||
if (isLogAll() || isLogConsumerEvents()) {
|
if (isLogAll() || isLogConsumerEvents()) {
|
||||||
LOG.info("Removing subscription : " + info);
|
LOG.info("Removing subscription : " + info);
|
||||||
}
|
}
|
||||||
|
@ -223,8 +212,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransactionId[] getPreparedTransactions(ConnectionContext context)
|
public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception {
|
||||||
throws Exception {
|
|
||||||
|
|
||||||
TransactionId[] result = super.getPreparedTransactions(context);
|
TransactionId[] result = super.getPreparedTransactions(context);
|
||||||
if ((isLogAll() || isLogTransactionEvents()) && result != null) {
|
if ((isLogAll() || isLogTransactionEvents()) && result != null) {
|
||||||
|
@ -241,8 +229,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int prepareTransaction(ConnectionContext context, TransactionId xid)
|
public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogTransactionEvents()) {
|
if (isLogAll() || isLogTransactionEvents()) {
|
||||||
LOG.info("Preparing transaction : " + xid.getTransactionKey());
|
LOG.info("Preparing transaction : " + xid.getTransactionKey());
|
||||||
}
|
}
|
||||||
|
@ -250,8 +237,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeConnection(ConnectionContext context,
|
public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception {
|
||||||
ConnectionInfo info, Throwable error) throws Exception {
|
|
||||||
if (isLogAll() || isLogConnectionEvents()) {
|
if (isLogAll() || isLogConnectionEvents()) {
|
||||||
LOG.info("Removing Connection : " + info);
|
LOG.info("Removing Connection : " + info);
|
||||||
}
|
}
|
||||||
|
@ -259,8 +245,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeConsumer(ConnectionContext context, ConsumerInfo info)
|
public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogConsumerEvents()) {
|
if (isLogAll() || isLogConsumerEvents()) {
|
||||||
LOG.info("Removing Consumer : " + info);
|
LOG.info("Removing Consumer : " + info);
|
||||||
}
|
}
|
||||||
|
@ -268,8 +253,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeProducer(ConnectionContext context, ProducerInfo info)
|
public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogProducerEvents()) {
|
if (isLogAll() || isLogProducerEvents()) {
|
||||||
LOG.info("Removing Producer : " + info);
|
LOG.info("Removing Producer : " + info);
|
||||||
}
|
}
|
||||||
|
@ -277,8 +261,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rollbackTransaction(ConnectionContext context, TransactionId xid)
|
public void rollbackTransaction(ConnectionContext context, TransactionId xid) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogTransactionEvents()) {
|
if (isLogAll() || isLogTransactionEvents()) {
|
||||||
LOG.info("Rolling back Transaction : " + xid.getTransactionKey());
|
LOG.info("Rolling back Transaction : " + xid.getTransactionKey());
|
||||||
}
|
}
|
||||||
|
@ -286,8 +269,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void send(ProducerBrokerExchange producerExchange,
|
public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception {
|
||||||
Message messageSend) throws Exception {
|
|
||||||
if (isLogAll() || isLogProducerEvents()) {
|
if (isLogAll() || isLogProducerEvents()) {
|
||||||
LOG.info("Sending message : " + messageSend);
|
LOG.info("Sending message : " + messageSend);
|
||||||
}
|
}
|
||||||
|
@ -295,8 +277,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beginTransaction(ConnectionContext context, TransactionId xid)
|
public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogTransactionEvents()) {
|
if (isLogAll() || isLogTransactionEvents()) {
|
||||||
LOG.info("Beginning transaction : " + xid.getTransactionKey());
|
LOG.info("Beginning transaction : " + xid.getTransactionKey());
|
||||||
}
|
}
|
||||||
|
@ -304,11 +285,9 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forgetTransaction(ConnectionContext context,
|
public void forgetTransaction(ConnectionContext context, TransactionId transactionId) throws Exception {
|
||||||
TransactionId transactionId) throws Exception {
|
|
||||||
if (isLogAll() || isLogTransactionEvents()) {
|
if (isLogAll() || isLogTransactionEvents()) {
|
||||||
LOG.info("Forgetting transaction : "
|
LOG.info("Forgetting transaction : " + transactionId.getTransactionKey());
|
||||||
+ transactionId.getTransactionKey());
|
|
||||||
}
|
}
|
||||||
super.forgetTransaction(context, transactionId);
|
super.forgetTransaction(context, transactionId);
|
||||||
}
|
}
|
||||||
|
@ -333,23 +312,20 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.apache.activemq.broker.region.Destination addDestination(
|
public org.apache.activemq.broker.region.Destination addDestination(ConnectionContext context,
|
||||||
ConnectionContext context, ActiveMQDestination destination,boolean create)
|
ActiveMQDestination destination, boolean create) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogInternalEvents()) {
|
if (isLogAll() || isLogInternalEvents()) {
|
||||||
LOG.info("Adding destination : "
|
LOG.info("Adding destination : " + destination.getDestinationTypeAsString() + ":"
|
||||||
+ destination.getDestinationTypeAsString() + ":"
|
|
||||||
+ destination.getPhysicalName());
|
+ destination.getPhysicalName());
|
||||||
}
|
}
|
||||||
return super.addDestination(context, destination,create);
|
return super.addDestination(context, destination, create);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeDestination(ConnectionContext context,
|
public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout)
|
||||||
ActiveMQDestination destination, long timeout) throws Exception {
|
throws Exception {
|
||||||
if (isLogAll() || isLogInternalEvents()) {
|
if (isLogAll() || isLogInternalEvents()) {
|
||||||
LOG.info("Removing destination : "
|
LOG.info("Removing destination : " + destination.getDestinationTypeAsString() + ":"
|
||||||
+ destination.getDestinationTypeAsString() + ":"
|
|
||||||
+ destination.getPhysicalName());
|
+ destination.getPhysicalName());
|
||||||
}
|
}
|
||||||
super.removeDestination(context, destination, timeout);
|
super.removeDestination(context, destination, timeout);
|
||||||
|
@ -390,8 +366,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSession(ConnectionContext context, SessionInfo info)
|
public void addSession(ConnectionContext context, SessionInfo info) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogConnectionEvents()) {
|
if (isLogAll() || isLogConnectionEvents()) {
|
||||||
LOG.info("Adding Session : " + info);
|
LOG.info("Adding Session : " + info);
|
||||||
}
|
}
|
||||||
|
@ -399,8 +374,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeSession(ConnectionContext context, SessionInfo info)
|
public void removeSession(ConnectionContext context, SessionInfo info) throws Exception {
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogConnectionEvents()) {
|
if (isLogAll() || isLogConnectionEvents()) {
|
||||||
LOG.info("Removing Session : " + info);
|
LOG.info("Removing Session : " + info);
|
||||||
}
|
}
|
||||||
|
@ -458,12 +432,9 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processDispatchNotification(
|
public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception {
|
||||||
MessageDispatchNotification messageDispatchNotification)
|
|
||||||
throws Exception {
|
|
||||||
if (isLogAll() || isLogInternalEvents() || isLogConsumerEvents()) {
|
if (isLogAll() || isLogInternalEvents() || isLogConsumerEvents()) {
|
||||||
LOG.info("ProcessDispatchNotification :"
|
LOG.info("ProcessDispatchNotification :" + messageDispatchNotification);
|
||||||
+ messageDispatchNotification);
|
|
||||||
}
|
}
|
||||||
super.processDispatchNotification(messageDispatchNotification);
|
super.processDispatchNotification(messageDispatchNotification);
|
||||||
}
|
}
|
||||||
|
@ -487,8 +458,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addDestinationInfo(ConnectionContext context,
|
public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
|
||||||
DestinationInfo info) throws Exception {
|
|
||||||
if (isLogAll() || isLogInternalEvents()) {
|
if (isLogAll() || isLogInternalEvents()) {
|
||||||
LOG.info("Adding destination info : " + info);
|
LOG.info("Adding destination info : " + info);
|
||||||
}
|
}
|
||||||
|
@ -496,8 +466,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeDestinationInfo(ConnectionContext context,
|
public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
|
||||||
DestinationInfo info) throws Exception {
|
|
||||||
if (isLogAll() || isLogInternalEvents()) {
|
if (isLogAll() || isLogInternalEvents()) {
|
||||||
LOG.info("Removing destination info : " + info);
|
LOG.info("Removing destination info : " + info);
|
||||||
}
|
}
|
||||||
|
@ -505,36 +474,31 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageExpired(ConnectionContext context,
|
public void messageExpired(ConnectionContext context, MessageReference message) {
|
||||||
MessageReference message) {
|
|
||||||
if (isLogAll() || isLogInternalEvents()) {
|
if (isLogAll() || isLogInternalEvents()) {
|
||||||
String msg = "Unable to display message.";
|
String msg = "Unable to display message.";
|
||||||
try {
|
|
||||||
msg = message.getMessage().toString();
|
msg = message.getMessage().toString();
|
||||||
} catch (IOException ioe) {
|
|
||||||
}
|
|
||||||
LOG.info("Message has expired : " + msg);
|
LOG.info("Message has expired : " + msg);
|
||||||
}
|
}
|
||||||
super.messageExpired(context, message);
|
super.messageExpired(context, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendToDeadLetterQueue(ConnectionContext context,
|
public void sendToDeadLetterQueue(ConnectionContext context, MessageReference messageReference) {
|
||||||
MessageReference messageReference) {
|
|
||||||
if (isLogAll() || isLogInternalEvents()) {
|
if (isLogAll() || isLogInternalEvents()) {
|
||||||
String msg = "Unable to display message.";
|
String msg = "Unable to display message.";
|
||||||
try {
|
|
||||||
msg = messageReference.getMessage().toString();
|
msg = messageReference.getMessage().toString();
|
||||||
} catch (IOException ioe) {
|
|
||||||
}
|
|
||||||
LOG.info("Sending to DLQ : " + msg);
|
LOG.info("Sending to DLQ : " + msg);
|
||||||
}
|
}
|
||||||
super.sendToDeadLetterQueue(context, messageReference);
|
super.sendToDeadLetterQueue(context, messageReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fastProducer(ConnectionContext context,
|
public void fastProducer(ConnectionContext context, ProducerInfo producerInfo) {
|
||||||
ProducerInfo producerInfo) {
|
|
||||||
if (isLogAll() || isLogProducerEvents() || isLogInternalEvents()) {
|
if (isLogAll() || isLogProducerEvents() || isLogInternalEvents()) {
|
||||||
LOG.info("Fast Producer : " + producerInfo);
|
LOG.info("Fast Producer : " + producerInfo);
|
||||||
}
|
}
|
||||||
|
@ -542,8 +506,7 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void isFull(ConnectionContext context, Destination destination,
|
public void isFull(ConnectionContext context, Destination destination, Usage usage) {
|
||||||
Usage usage) {
|
|
||||||
if (isLogAll() || isLogProducerEvents() || isLogInternalEvents()) {
|
if (isLogAll() || isLogProducerEvents() || isLogInternalEvents()) {
|
||||||
LOG.info("Destination is full : " + destination.getName());
|
LOG.info("Destination is full : " + destination.getName());
|
||||||
}
|
}
|
||||||
|
@ -551,50 +514,43 @@ public class LoggingBrokerPlugin extends BrokerPluginSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageConsumed(ConnectionContext context,
|
public void messageConsumed(ConnectionContext context, MessageReference messageReference) {
|
||||||
MessageReference messageReference) {
|
|
||||||
if (isLogAll() || isLogConsumerEvents() || isLogInternalEvents()) {
|
if (isLogAll() || isLogConsumerEvents() || isLogInternalEvents()) {
|
||||||
String msg = "Unable to display message.";
|
String msg = "Unable to display message.";
|
||||||
try {
|
|
||||||
msg = messageReference.getMessage().toString();
|
msg = messageReference.getMessage().toString();
|
||||||
} catch (IOException ioe) {
|
|
||||||
}
|
|
||||||
LOG.info("Message consumed : " + msg);
|
LOG.info("Message consumed : " + msg);
|
||||||
}
|
}
|
||||||
super.messageConsumed(context, messageReference);
|
super.messageConsumed(context, messageReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageDelivered(ConnectionContext context,
|
public void messageDelivered(ConnectionContext context, MessageReference messageReference) {
|
||||||
MessageReference messageReference) {
|
|
||||||
if (isLogAll() || isLogConsumerEvents() || isLogInternalEvents()) {
|
if (isLogAll() || isLogConsumerEvents() || isLogInternalEvents()) {
|
||||||
String msg = "Unable to display message.";
|
String msg = "Unable to display message.";
|
||||||
try {
|
|
||||||
msg = messageReference.getMessage().toString();
|
msg = messageReference.getMessage().toString();
|
||||||
} catch (IOException ioe) {
|
|
||||||
}
|
|
||||||
LOG.info("Message delivered : " + msg);
|
LOG.info("Message delivered : " + msg);
|
||||||
}
|
}
|
||||||
super.messageDelivered(context, messageReference);
|
super.messageDelivered(context, messageReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageDiscarded(ConnectionContext context, Subscription sub,
|
public void messageDiscarded(ConnectionContext context, Subscription sub, MessageReference messageReference) {
|
||||||
MessageReference messageReference) {
|
|
||||||
if (isLogAll() || isLogInternalEvents()) {
|
if (isLogAll() || isLogInternalEvents()) {
|
||||||
String msg = "Unable to display message.";
|
String msg = "Unable to display message.";
|
||||||
try {
|
|
||||||
msg = messageReference.getMessage().toString();
|
msg = messageReference.getMessage().toString();
|
||||||
} catch (IOException ioe) {
|
|
||||||
}
|
|
||||||
LOG.info("Message discarded : " + msg);
|
LOG.info("Message discarded : " + msg);
|
||||||
}
|
}
|
||||||
super.messageDiscarded(context, sub, messageReference);
|
super.messageDiscarded(context, sub, messageReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void slowConsumer(ConnectionContext context,
|
public void slowConsumer(ConnectionContext context, Destination destination, Subscription subs) {
|
||||||
Destination destination, Subscription subs) {
|
|
||||||
if (isLogAll() || isLogConsumerEvents() || isLogInternalEvents()) {
|
if (isLogAll() || isLogConsumerEvents() || isLogInternalEvents()) {
|
||||||
LOG.info("Detected slow consumer on " + destination.getName());
|
LOG.info("Detected slow consumer on " + destination.getName());
|
||||||
StringBuffer buf = new StringBuffer("Connection(");
|
StringBuffer buf = new StringBuffer("Connection(");
|
||||||
|
|
|
@ -564,7 +564,7 @@ public abstract class Message extends BaseCommand implements MarshallAware, Mess
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message getMessage() throws IOException {
|
public Message getMessage() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.memory.list;
|
package org.apache.activemq.memory.list;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -38,10 +37,10 @@ import org.apache.commons.logging.LogFactory;
|
||||||
*/
|
*/
|
||||||
public class SimpleMessageList implements MessageList {
|
public class SimpleMessageList implements MessageList {
|
||||||
private static final Log LOG = LogFactory.getLog(SimpleMessageList.class);
|
private static final Log LOG = LogFactory.getLog(SimpleMessageList.class);
|
||||||
private LinkedList<MessageReference> list = new LinkedList<MessageReference>();
|
private final LinkedList<MessageReference> list = new LinkedList<MessageReference>();
|
||||||
private int maximumSize = 100 * 64 * 1024;
|
private int maximumSize = 100 * 64 * 1024;
|
||||||
private int size;
|
private int size;
|
||||||
private Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
|
|
||||||
public SimpleMessageList() {
|
public SimpleMessageList() {
|
||||||
}
|
}
|
||||||
|
@ -73,13 +72,9 @@ public class SimpleMessageList implements MessageList {
|
||||||
for (Iterator<MessageReference> i = list.iterator(); i.hasNext();) {
|
for (Iterator<MessageReference> i = list.iterator(); i.hasNext();) {
|
||||||
MessageReference ref = i.next();
|
MessageReference ref = i.next();
|
||||||
Message msg;
|
Message msg;
|
||||||
try {
|
msg = ref.getMessage();
|
||||||
msg = ref.getMessage();
|
if (filter.matches(msg.getDestination())) {
|
||||||
if (filter.matches(msg.getDestination())) {
|
result.add(msg);
|
||||||
result.add(msg);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.error("Failed to get Message from MessageReference: " + ref, e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.plugin;
|
package org.apache.activemq.plugin;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.activemq.broker.Broker;
|
import org.apache.activemq.broker.Broker;
|
||||||
import org.apache.activemq.broker.BrokerFilter;
|
import org.apache.activemq.broker.BrokerFilter;
|
||||||
import org.apache.activemq.broker.ConnectionContext;
|
import org.apache.activemq.broker.ConnectionContext;
|
||||||
|
@ -48,25 +46,15 @@ public class DiscardingDLQBroker extends BrokerFilter {
|
||||||
@Override
|
@Override
|
||||||
public void sendToDeadLetterQueue(ConnectionContext ctx, MessageReference msgRef) {
|
public void sendToDeadLetterQueue(ConnectionContext ctx, MessageReference msgRef) {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
try {
|
log.trace("Discarding DLQ BrokerFilter[pass through] - skipping message:" + (msgRef != null ? msgRef.getMessage() : null));
|
||||||
log.trace("Discarding DLQ BrokerFilter[pass through] - skipping message:" + (msgRef != null ? msgRef.getMessage() : null));
|
|
||||||
} catch (IOException x) {
|
|
||||||
log.trace("Discarding DLQ BrokerFilter[pass through] - skipping message:" + msgRef != null ? msgRef : null, x);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
boolean dropped = true;
|
boolean dropped = true;
|
||||||
Message msg = null;
|
Message msg = null;
|
||||||
ActiveMQDestination dest = null;
|
ActiveMQDestination dest = null;
|
||||||
String destName = null;
|
String destName = null;
|
||||||
try {
|
msg = msgRef.getMessage();
|
||||||
msg = msgRef.getMessage();
|
dest = msg.getDestination();
|
||||||
dest = msg.getDestination();
|
destName = dest.getPhysicalName();
|
||||||
destName = dest.getPhysicalName();
|
|
||||||
}catch (IOException x) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Unable to retrieve message or destination for message going to Dead Letter Queue. message skipped.", x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dest == null || destName == null ) {
|
if (dest == null || destName == null ) {
|
||||||
//do nothing, no need to forward it
|
//do nothing, no need to forward it
|
||||||
|
@ -105,12 +93,8 @@ public class DiscardingDLQBroker extends BrokerFilter {
|
||||||
|
|
||||||
private void skipMessage(String prefix, MessageReference msgRef) {
|
private void skipMessage(String prefix, MessageReference msgRef) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
try {
|
String lmsg = "Discarding DLQ BrokerFilter["+prefix+"] - skipping message:" + (msgRef!=null?msgRef.getMessage():null);
|
||||||
String lmsg = "Discarding DLQ BrokerFilter["+prefix+"] - skipping message:" + (msgRef!=null?msgRef.getMessage():null);
|
log.debug(lmsg);
|
||||||
log.debug(lmsg);
|
|
||||||
}catch (IOException x) {
|
|
||||||
log.debug("Discarding DLQ BrokerFilter["+prefix+"] - skipping message:" + (msgRef!=null?msgRef:null),x);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue