mirror of
https://github.com/apache/activemq.git
synced 2025-02-28 05:09:07 +00:00
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@614206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
17e22cff6f
commit
23cda2d6bb
@ -93,7 +93,7 @@ public class BrokerView implements BrokerViewMBean {
|
|||||||
return broker.getDestinationStatistics().getMessagesCached().getCount();
|
return broker.getDestinationStatistics().getMessagesCached().getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMemoryPercentageUsed() {
|
public int getMemoryPercentUsage() {
|
||||||
return brokerService.getSystemUsage().getMemoryUsage().getPercentUsage();
|
return brokerService.getSystemUsage().getMemoryUsage().getPercentUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,16 +109,16 @@ public class BrokerView implements BrokerViewMBean {
|
|||||||
return brokerService.getSystemUsage().getStoreUsage().getLimit();
|
return brokerService.getSystemUsage().getStoreUsage().getLimit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStorePercentageUsed() {
|
public int getStorePercentUsage() {
|
||||||
return brokerService.getSystemUsage().getStoreUsage().getPercentUsage();
|
return brokerService.getSystemUsage().getStoreUsage().getPercentUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public long getTmpLimit() {
|
public long getTempLimit() {
|
||||||
return brokerService.getSystemUsage().getTempUsage().getLimit();
|
return brokerService.getSystemUsage().getTempUsage().getLimit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTmpPercentageUsed() {
|
public int getTempPercentUsage() {
|
||||||
return brokerService.getSystemUsage().getTempUsage().getPercentUsage();
|
return brokerService.getSystemUsage().getTempUsage().getPercentUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public class BrokerView implements BrokerViewMBean {
|
|||||||
brokerService.getSystemUsage().getStoreUsage().setLimit(limit);
|
brokerService.getSystemUsage().getStoreUsage().setLimit(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTmpLimit(long limit) {
|
public void setTempLimit(long limit) {
|
||||||
brokerService.getSystemUsage().getTempUsage().setLimit(limit);
|
brokerService.getSystemUsage().getTempUsage().setLimit(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ public class BrokerView implements BrokerViewMBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ObjectName[] getTopicSubscribers() {
|
public ObjectName[] getTopicSubscribers() {
|
||||||
return broker.getTemporaryTopicSubscribers();
|
return broker.getTopicSubscribers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectName[] getDurableTopicSubscribers() {
|
public ObjectName[] getDurableTopicSubscribers() {
|
||||||
|
@ -61,23 +61,23 @@ public interface BrokerViewMBean extends Service {
|
|||||||
|
|
||||||
long getTotalMessageCount();
|
long getTotalMessageCount();
|
||||||
|
|
||||||
int getMemoryPercentageUsed();
|
int getMemoryPercentUsage();
|
||||||
|
|
||||||
long getMemoryLimit();
|
long getMemoryLimit();
|
||||||
|
|
||||||
void setMemoryLimit(long limit);
|
void setMemoryLimit(long limit);
|
||||||
|
|
||||||
int getStorePercentageUsed();
|
int getStorePercentUsage();
|
||||||
|
|
||||||
long getStoreLimit();
|
long getStoreLimit();
|
||||||
|
|
||||||
void setStoreLimit(long limit);
|
void setStoreLimit(long limit);
|
||||||
|
|
||||||
int getTmpPercentageUsed();
|
int getTempPercentUsage();
|
||||||
|
|
||||||
long getTmpLimit();
|
long getTempLimit();
|
||||||
|
|
||||||
void setTmpLimit(long limit);
|
void setTempLimit(long limit);
|
||||||
|
|
||||||
boolean isPersistent();
|
boolean isPersistent();
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class DestinationView implements DestinationViewMBean {
|
|||||||
return destination.getDestinationStatistics().getMessagesCached().getCount();
|
return destination.getDestinationStatistics().getMessagesCached().getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMemoryPercentageUsed() {
|
public int getMemoryPercentUsage() {
|
||||||
return destination.getMemoryUsage().getPercentUsage();
|
return destination.getMemoryUsage().getPercentUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ public class DestinationView implements DestinationViewMBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public float getMemoryLimitPortion() {
|
public float getMemoryUsagePortion() {
|
||||||
return destination.getMemoryUsage().getUsagePortion();
|
return destination.getMemoryUsage().getUsagePortion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ public class DestinationView implements DestinationViewMBean {
|
|||||||
return destination.isProducerFlowControl();
|
return destination.isProducerFlowControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMemoryLimitPortion(float value) {
|
public void setMemoryUsagePortion(float value) {
|
||||||
destination.getMemoryUsage().setUsagePortion(value);
|
destination.getMemoryUsage().setUsagePortion(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ public interface DestinationViewMBean {
|
|||||||
/**
|
/**
|
||||||
* @return the percentage of amount of memory used
|
* @return the percentage of amount of memory used
|
||||||
*/
|
*/
|
||||||
int getMemoryPercentageUsed();
|
int getMemoryPercentUsage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the amount of memory allocated to this destination
|
* @return the amount of memory allocated to this destination
|
||||||
@ -143,13 +143,13 @@ public interface DestinationViewMBean {
|
|||||||
/**
|
/**
|
||||||
* @return the portion of memory from the broker memory limit for this destination
|
* @return the portion of memory from the broker memory limit for this destination
|
||||||
*/
|
*/
|
||||||
float getMemoryLimitPortion();
|
float getMemoryUsagePortion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the portion of memory from the broker memory limit for this destination
|
* set the portion of memory from the broker memory limit for this destination
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
void setMemoryLimitPortion(float value);
|
void setMemoryUsagePortion(float value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Browses the current destination returning a list of messages
|
* Browses the current destination returning a list of messages
|
||||||
|
@ -139,10 +139,7 @@ public abstract class BaseDestination implements Destination {
|
|||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getDestination() {
|
|
||||||
return destination.getPhysicalName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getName() {
|
public final String getName() {
|
||||||
return getActiveMQDestination().getPhysicalName();
|
return getActiveMQDestination().getPhysicalName();
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class DestinationFactoryImpl extends DestinationFactory {
|
|||||||
if (destination.isQueue()) {
|
if (destination.isQueue()) {
|
||||||
if (destination.isTemporary()) {
|
if (destination.isTemporary()) {
|
||||||
final ActiveMQTempDestination tempDest = (ActiveMQTempDestination)destination;
|
final ActiveMQTempDestination tempDest = (ActiveMQTempDestination)destination;
|
||||||
return new Queue(broker.getRoot(), destination, memoryManager, null, destinationStatistics, taskRunnerFactory, broker.getTempDataStore()) {
|
return new Queue(broker.getRoot(), destination, memoryManager, null, destinationStatistics, taskRunnerFactory) {
|
||||||
|
|
||||||
public void addSubscription(ConnectionContext context, Subscription sub) throws Exception {
|
public void addSubscription(ConnectionContext context, Subscription sub) throws Exception {
|
||||||
// Only consumers on the same connection can consume
|
// Only consumers on the same connection can consume
|
||||||
@ -90,7 +90,7 @@ public class DestinationFactoryImpl extends DestinationFactory {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
MessageStore store = persistenceAdapter.createQueueMessageStore((ActiveMQQueue)destination);
|
MessageStore store = persistenceAdapter.createQueueMessageStore((ActiveMQQueue)destination);
|
||||||
Queue queue = new Queue(broker.getRoot(), destination, memoryManager, store, destinationStatistics, taskRunnerFactory, broker.getTempDataStore());
|
Queue queue = new Queue(broker.getRoot(), destination, memoryManager, store, destinationStatistics, taskRunnerFactory);
|
||||||
configureQueue(queue, destination);
|
configureQueue(queue, destination);
|
||||||
queue.initialize();
|
queue.initialize();
|
||||||
return queue;
|
return queue;
|
||||||
@ -127,7 +127,7 @@ public class DestinationFactoryImpl extends DestinationFactory {
|
|||||||
if (broker.getDestinationPolicy() != null) {
|
if (broker.getDestinationPolicy() != null) {
|
||||||
PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(destination);
|
PolicyEntry entry = broker.getDestinationPolicy().getEntryFor(destination);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
entry.configure(queue, broker.getTempDataStore());
|
entry.configure(broker,queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class DurableTopicSubscription extends PrefetchSubscription implements Us
|
|||||||
public DurableTopicSubscription(Broker broker, Destination dest,SystemUsage usageManager, ConnectionContext context, ConsumerInfo info, boolean keepDurableSubsActive)
|
public DurableTopicSubscription(Broker broker, Destination dest,SystemUsage usageManager, ConnectionContext context, ConsumerInfo info, boolean keepDurableSubsActive)
|
||||||
throws JMSException {
|
throws JMSException {
|
||||||
super(broker,usageManager, context, info);
|
super(broker,usageManager, context, info);
|
||||||
this.pending = new StoreDurableSubscriberCursor(context.getClientId(), info.getSubscriptionName(), broker.getTempDataStore(), info.getPrefetchSize(), this);
|
this.pending = new StoreDurableSubscriberCursor(broker,context.getClientId(), info.getSubscriptionName(), info.getPrefetchSize(), this);
|
||||||
this.pending.setSystemUsage(usageManager);
|
this.pending.setSystemUsage(usageManager);
|
||||||
this.keepDurableSubsActive = keepDurableSubsActive;
|
this.keepDurableSubsActive = keepDurableSubsActive;
|
||||||
subscriptionKey = new SubscriptionKey(context.getClientId(), info.getSubscriptionName());
|
subscriptionKey = new SubscriptionKey(context.getClientId(), info.getSubscriptionName());
|
||||||
@ -218,19 +218,12 @@ public class DurableTopicSubscription extends PrefetchSubscription implements Us
|
|||||||
node.decrementReferenceCount();
|
node.decrementReferenceCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSubscriptionName() {
|
|
||||||
return subscriptionKey.getSubscriptionName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized String toString() {
|
public synchronized String toString() {
|
||||||
return "DurableTopicSubscription:" + " consumer=" + info.getConsumerId() + ", destinations=" + destinations.size() + ", total=" + enqueueCounter + ", pending="
|
return "DurableTopicSubscription:" + " consumer=" + info.getConsumerId() + ", destinations=" + destinations.size() + ", total=" + enqueueCounter + ", pending="
|
||||||
+ getPendingQueueSize() + ", dispatched=" + dispatchCounter + ", inflight=" + dispatched.size() + ", prefetchExtension=" + this.prefetchExtension;
|
+ getPendingQueueSize() + ", dispatched=" + dispatchCounter + ", inflight=" + dispatched.size() + ", prefetchExtension=" + this.prefetchExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClientId() {
|
|
||||||
return subscriptionKey.getClientId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionKey getSubscriptionKey() {
|
public SubscriptionKey getSubscriptionKey() {
|
||||||
return subscriptionKey;
|
return subscriptionKey;
|
||||||
}
|
}
|
||||||
|
@ -95,14 +95,14 @@ public class Queue extends BaseDestination implements Task {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
public Queue(Broker broker, ActiveMQDestination destination, final SystemUsage systemUsage, MessageStore store, DestinationStatistics parentStats,
|
public Queue(Broker broker, ActiveMQDestination destination, final SystemUsage systemUsage,MessageStore store,DestinationStatistics parentStats,
|
||||||
TaskRunnerFactory taskFactory, Store tmpStore) throws Exception {
|
TaskRunnerFactory taskFactory) throws Exception {
|
||||||
super(broker, store, destination,systemUsage, parentStats);
|
super(broker, store, destination,systemUsage, parentStats);
|
||||||
|
|
||||||
if (destination.isTemporary() || tmpStore==null ) {
|
if (destination.isTemporary() || broker == null || store==null ) {
|
||||||
this.messages = new VMPendingMessageCursor();
|
this.messages = new VMPendingMessageCursor();
|
||||||
} else {
|
} else {
|
||||||
this.messages = new StoreQueueCursor(this, tmpStore);
|
this.messages = new StoreQueueCursor(broker,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.taskRunner = taskFactory.createTaskRunner(this, "Queue " + destination.getPhysicalName());
|
this.taskRunner = taskFactory.createTaskRunner(this, "Queue " + destination.getPhysicalName());
|
||||||
@ -318,11 +318,11 @@ public class Queue extends BaseDestination implements Task {
|
|||||||
final ConnectionContext context = producerExchange.getConnectionContext();
|
final ConnectionContext context = producerExchange.getConnectionContext();
|
||||||
// There is delay between the client sending it and it arriving at the
|
// There is delay between the client sending it and it arriving at the
|
||||||
// destination.. it may have expired.
|
// destination.. it may have expired.
|
||||||
|
message.setRegionDestination(this);
|
||||||
final ProducerInfo producerInfo = producerExchange.getProducerState().getInfo();
|
final ProducerInfo producerInfo = producerExchange.getProducerState().getInfo();
|
||||||
final boolean sendProducerAck = !message.isResponseRequired() && producerInfo.getWindowSize() > 0 && !context.isInRecoveryMode();
|
final boolean sendProducerAck = !message.isResponseRequired() && producerInfo.getWindowSize() > 0 && !context.isInRecoveryMode();
|
||||||
if (message.isExpired()) {
|
if (message.isExpired()) {
|
||||||
broker.messageExpired(context, message);
|
broker.getRoot().messageExpired(context, message);
|
||||||
//message not added to stats yet
|
//message not added to stats yet
|
||||||
//destinationStatistics.getMessages().decrement();
|
//destinationStatistics.getMessages().decrement();
|
||||||
if (sendProducerAck) {
|
if (sendProducerAck) {
|
||||||
@ -402,6 +402,7 @@ public class Queue extends BaseDestination implements Task {
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Expired message: " + message);
|
log.debug("Expired message: " + message);
|
||||||
}
|
}
|
||||||
|
broker.getRoot().messageExpired(context, message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -416,7 +417,6 @@ public class Queue extends BaseDestination implements Task {
|
|||||||
void doMessageSend(final ProducerBrokerExchange producerExchange, final Message message) throws IOException, Exception {
|
void doMessageSend(final ProducerBrokerExchange producerExchange, final Message message) throws IOException, Exception {
|
||||||
final ConnectionContext context = producerExchange.getConnectionContext();
|
final ConnectionContext context = producerExchange.getConnectionContext();
|
||||||
synchronized (sendLock) {
|
synchronized (sendLock) {
|
||||||
message.setRegionDestination(this);
|
|
||||||
if (store != null && message.isPersistent()) {
|
if (store != null && message.isPersistent()) {
|
||||||
while (!systemUsage.getStoreUsage().waitForSpace(1000)) {
|
while (!systemUsage.getStoreUsage().waitForSpace(1000)) {
|
||||||
if (context.getStopping().get()) {
|
if (context.getStopping().get()) {
|
||||||
@ -678,11 +678,7 @@ public class Queue extends BaseDestination implements Task {
|
|||||||
|
|
||||||
// We should only delete messages that can be locked.
|
// We should only delete messages that can be locked.
|
||||||
if (r.lock(LockOwner.HIGH_PRIORITY_LOCK_OWNER)) {
|
if (r.lock(LockOwner.HIGH_PRIORITY_LOCK_OWNER)) {
|
||||||
MessageAck ack = new MessageAck();
|
removeMessage(c,(IndirectMessageReference) r);
|
||||||
ack.setAckType(MessageAck.STANDARD_ACK_TYPE);
|
|
||||||
ack.setDestination(destination);
|
|
||||||
ack.setMessageID(r.getMessageId());
|
|
||||||
removeMessage(c, null, r, ack);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
|
@ -705,14 +705,18 @@ public class RegionBroker implements Broker {
|
|||||||
deadLetterDestination);
|
deadLetterDestination);
|
||||||
sent=true;
|
sent=true;
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
//don't want to warn about failing to send
|
||||||
|
// if there isn't a dead letter strategy
|
||||||
|
sent=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(sent==false){
|
if(sent==false){
|
||||||
LOG.warn("Failed to send "+node+" to dead letter queue");
|
LOG.warn("Failed to send "+node+" to DLQ");
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
LOG.warn("Failed to pass expired message to dead letter queue",e);
|
LOG.warn("Caught an exception sending to DLQ: "+node,e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class TempQueueRegion extends AbstractRegion {
|
|||||||
|
|
||||||
protected Destination createDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception {
|
protected Destination createDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception {
|
||||||
final ActiveMQTempDestination tempDest = (ActiveMQTempDestination)destination;
|
final ActiveMQTempDestination tempDest = (ActiveMQTempDestination)destination;
|
||||||
return new Queue(broker.getRoot(), destination, usageManager, null, destinationStatistics, taskRunnerFactory, null) {
|
return new Queue(broker.getRoot(), destination, usageManager, null, destinationStatistics, taskRunnerFactory) {
|
||||||
|
|
||||||
public void addSubscription(ConnectionContext context, Subscription sub) throws Exception {
|
public void addSubscription(ConnectionContext context, Subscription sub) throws Exception {
|
||||||
|
|
||||||
|
@ -184,8 +184,8 @@ public class Topic extends BaseDestination implements Task{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recover the durable subscription.
|
// Recover the durable subscription.
|
||||||
String clientId = subscription.getClientId();
|
String clientId = subscription.getSubscriptionKey().getClientId();
|
||||||
String subscriptionName = subscription.getSubscriptionName();
|
String subscriptionName = subscription.getSubscriptionKey().getSubscriptionName();
|
||||||
String selector = subscription.getConsumerInfo().getSelector();
|
String selector = subscription.getConsumerInfo().getSelector();
|
||||||
SubscriptionInfo info = topicStore.lookupSubscription(clientId, subscriptionName);
|
SubscriptionInfo info = topicStore.lookupSubscription(clientId, subscriptionName);
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
@ -435,7 +435,8 @@ public class Topic extends BaseDestination implements Task{
|
|||||||
public void acknowledge(ConnectionContext context, Subscription sub, final MessageAck ack, final MessageReference node) throws IOException {
|
public void acknowledge(ConnectionContext context, Subscription sub, final MessageAck ack, final MessageReference node) throws IOException {
|
||||||
if (topicStore != null && node.isPersistent()) {
|
if (topicStore != null && node.isPersistent()) {
|
||||||
DurableTopicSubscription dsub = (DurableTopicSubscription)sub;
|
DurableTopicSubscription dsub = (DurableTopicSubscription)sub;
|
||||||
topicStore.acknowledge(context, dsub.getClientId(), dsub.getSubscriptionName(), node.getMessageId());
|
SubscriptionKey key = dsub.getSubscriptionKey();
|
||||||
|
topicStore.acknowledge(context, key.getClientId(), key.getSubscriptionName(), node.getMessageId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,11 +68,10 @@ public class TopicSubscription extends AbstractSubscription {
|
|||||||
super(broker, context, info);
|
super(broker, context, info);
|
||||||
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() + "]";
|
||||||
Store tempDataStore = broker.getTempDataStore();
|
if (info.getDestination().isTemporary() || broker == null || broker.getTempDataStore()==null ) {
|
||||||
if (tempDataStore != null) {
|
|
||||||
this.matched = new FilePendingMessageCursor(matchedName, tempDataStore);
|
|
||||||
} else {
|
|
||||||
this.matched = new VMPendingMessageCursor();
|
this.matched = new VMPendingMessageCursor();
|
||||||
|
} else {
|
||||||
|
this.matched = new FilePendingMessageCursor(broker,matchedName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,9 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
import org.apache.activemq.broker.Broker;
|
||||||
|
import org.apache.activemq.broker.ConnectionContext;
|
||||||
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.QueueMessageReference;
|
import org.apache.activemq.broker.region.QueueMessageReference;
|
||||||
@ -32,6 +35,8 @@ import org.apache.activemq.openwire.OpenWireFormat;
|
|||||||
import org.apache.activemq.usage.SystemUsage;
|
import org.apache.activemq.usage.SystemUsage;
|
||||||
import org.apache.activemq.usage.Usage;
|
import org.apache.activemq.usage.Usage;
|
||||||
import org.apache.activemq.usage.UsageListener;
|
import org.apache.activemq.usage.UsageListener;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* persist pending messages pending message (messages awaiting dispatch to a
|
* persist pending messages pending message (messages awaiting dispatch to a
|
||||||
@ -40,14 +45,14 @@ import org.apache.activemq.usage.UsageListener;
|
|||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
public class FilePendingMessageCursor extends AbstractPendingMessageCursor implements UsageListener {
|
public class FilePendingMessageCursor extends AbstractPendingMessageCursor implements UsageListener {
|
||||||
|
private static final Log LOG = LogFactory.getLog(FilePendingMessageCursor.class);
|
||||||
private static final AtomicLong NAME_COUNT = new AtomicLong();
|
private static final AtomicLong NAME_COUNT = new AtomicLong();
|
||||||
|
protected Broker broker;
|
||||||
private Store store;
|
private Store store;
|
||||||
private String name;
|
private String name;
|
||||||
private LinkedList<MessageReference> memoryList = new LinkedList<MessageReference>();
|
private LinkedList<MessageReference> memoryList = new LinkedList<MessageReference>();
|
||||||
private ListContainer<MessageReference> diskList;
|
private ListContainer<MessageReference> diskList;
|
||||||
private Iterator iter;
|
private Iterator<MessageReference> iter;
|
||||||
private Destination regionDestination;
|
private Destination regionDestination;
|
||||||
private boolean iterating;
|
private boolean iterating;
|
||||||
private boolean flushRequired;
|
private boolean flushRequired;
|
||||||
@ -58,9 +63,10 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
|
|||||||
* @param name
|
* @param name
|
||||||
* @param store
|
* @param store
|
||||||
*/
|
*/
|
||||||
public FilePendingMessageCursor(String name, Store store) {
|
public FilePendingMessageCursor(Broker broker,String name) {
|
||||||
|
this.broker = broker;
|
||||||
|
this.store= broker.getTempDataStore();
|
||||||
this.name = NAME_COUNT.incrementAndGet() + "_" + name;
|
this.name = NAME_COUNT.incrementAndGet() + "_" + name;
|
||||||
this.store = store;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() throws Exception {
|
public void start() throws Exception {
|
||||||
@ -157,19 +163,39 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
|
|||||||
* @param node
|
* @param node
|
||||||
*/
|
*/
|
||||||
public synchronized void addMessageLast(MessageReference node) {
|
public synchronized void addMessageLast(MessageReference node) {
|
||||||
try {
|
if (!node.isExpired()) {
|
||||||
regionDestination = node.getMessage().getRegionDestination();
|
try {
|
||||||
if (isSpaceInMemoryList()) {
|
regionDestination = node.getMessage().getRegionDestination();
|
||||||
memoryList.add(node);
|
if (isDiskListEmpty()) {
|
||||||
node.incrementReferenceCount();
|
if (hasSpace()) {
|
||||||
} else {
|
memoryList.add(node);
|
||||||
flushToDisk();
|
node.incrementReferenceCount();
|
||||||
node.decrementReferenceCount();
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasSpace()) {
|
||||||
|
if (isDiskListEmpty()) {
|
||||||
|
expireOldMessages();
|
||||||
|
if (hasSpace()) {
|
||||||
|
memoryList.add(node);
|
||||||
|
node.incrementReferenceCount();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
flushToDisk();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
systemUsage.getTempUsage().waitForSpace();
|
systemUsage.getTempUsage().waitForSpace();
|
||||||
getDiskList().addLast(node);
|
node.decrementReferenceCount();
|
||||||
|
getDiskList().add(node);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Caught an Exception adding a message: " + node
|
||||||
|
+ " first to FilePendingMessageCursor ", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
throw new RuntimeException(e);
|
discard(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,19 +205,39 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
|
|||||||
* @param node
|
* @param node
|
||||||
*/
|
*/
|
||||||
public synchronized void addMessageFirst(MessageReference node) {
|
public synchronized void addMessageFirst(MessageReference node) {
|
||||||
try {
|
if (!node.isExpired()) {
|
||||||
regionDestination = node.getMessage().getRegionDestination();
|
try {
|
||||||
if (isSpaceInMemoryList()) {
|
regionDestination = node.getMessage().getRegionDestination();
|
||||||
memoryList.addFirst(node);
|
if (isDiskListEmpty()) {
|
||||||
node.incrementReferenceCount();
|
if (hasSpace()) {
|
||||||
} else {
|
memoryList.addFirst(node);
|
||||||
flushToDisk();
|
node.incrementReferenceCount();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasSpace()) {
|
||||||
|
if (isDiskListEmpty()) {
|
||||||
|
expireOldMessages();
|
||||||
|
if (hasSpace()) {
|
||||||
|
memoryList.addFirst(node);
|
||||||
|
node.incrementReferenceCount();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
flushToDisk();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
systemUsage.getTempUsage().waitForSpace();
|
systemUsage.getTempUsage().waitForSpace();
|
||||||
node.decrementReferenceCount();
|
node.decrementReferenceCount();
|
||||||
getDiskList().addFirst(node);
|
getDiskList().addFirst(node);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Caught an Exception adding a message: " + node
|
||||||
|
+ " first to FilePendingMessageCursor ", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
throw new RuntimeException(e);
|
discard(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,13 +317,17 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
|
|||||||
super.setSystemUsage(usageManager);
|
super.setSystemUsage(usageManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUsageChanged(Usage usage, int oldPercentUsage, int newPercentUsage) {
|
public void onUsageChanged(Usage usage, int oldPercentUsage,
|
||||||
|
int newPercentUsage) {
|
||||||
if (newPercentUsage >= getMemoryUsageHighWaterMark()) {
|
if (newPercentUsage >= getMemoryUsageHighWaterMark()) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
flushRequired = true;
|
flushRequired = true;
|
||||||
if (!iterating) {
|
if (!iterating) {
|
||||||
flushToDisk();
|
expireOldMessages();
|
||||||
flushRequired = false;
|
if (!hasSpace()) {
|
||||||
|
flushToDisk();
|
||||||
|
flushRequired = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,8 +340,25 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
|
|||||||
protected boolean isSpaceInMemoryList() {
|
protected boolean isSpaceInMemoryList() {
|
||||||
return hasSpace() && isDiskListEmpty();
|
return hasSpace() && isDiskListEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected synchronized void expireOldMessages() {
|
||||||
|
if (!memoryList.isEmpty()) {
|
||||||
|
LinkedList<MessageReference> tmpList = new LinkedList<MessageReference>(this.memoryList);
|
||||||
|
this.memoryList = new LinkedList<MessageReference>();
|
||||||
|
while (!tmpList.isEmpty()) {
|
||||||
|
MessageReference node = tmpList.removeFirst();
|
||||||
|
if (node.isExpired()) {
|
||||||
|
discard(node);
|
||||||
|
}else {
|
||||||
|
memoryList.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected synchronized void flushToDisk() {
|
protected synchronized void flushToDisk() {
|
||||||
|
|
||||||
if (!memoryList.isEmpty()) {
|
if (!memoryList.isEmpty()) {
|
||||||
while (!memoryList.isEmpty()) {
|
while (!memoryList.isEmpty()) {
|
||||||
MessageReference node = memoryList.removeFirst();
|
MessageReference node = memoryList.removeFirst();
|
||||||
@ -312,10 +379,18 @@ public class FilePendingMessageCursor extends AbstractPendingMessageCursor imple
|
|||||||
diskList = store.getListContainer(name, "TopicSubscription", true);
|
diskList = store.getListContainer(name, "TopicSubscription", true);
|
||||||
diskList.setMarshaller(new CommandMarshaller(new OpenWireFormat()));
|
diskList.setMarshaller(new CommandMarshaller(new OpenWireFormat()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
LOG.error("Caught an IO Exception getting the DiskList ",e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return diskList;
|
return diskList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void discard(MessageReference message) {
|
||||||
|
message.decrementReferenceCount();
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("Discarding message " + message);
|
||||||
|
}
|
||||||
|
broker.getRoot().sendToDeadLetterQueue(new ConnectionContext(), message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class QueueStorePrefetch extends AbstractPendingMessageCursor implements Message
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addMessageLast(MessageReference node) throws Exception {
|
public synchronized void addMessageLast(MessageReference node) throws Exception {
|
||||||
if (cacheEnabled && !isFull()) {
|
if (cacheEnabled && hasSpace()) {
|
||||||
//optimization - A persistent queue will add the message to
|
//optimization - A persistent queue will add the message to
|
||||||
//to store then retrieve it again from the store.
|
//to store then retrieve it again from the store.
|
||||||
recoverMessage(node.getMessage());
|
recoverMessage(node.getMessage());
|
||||||
|
@ -23,13 +23,13 @@ import java.util.LinkedList;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.activemq.advisory.AdvisorySupport;
|
import org.apache.activemq.advisory.AdvisorySupport;
|
||||||
|
import org.apache.activemq.broker.Broker;
|
||||||
import org.apache.activemq.broker.ConnectionContext;
|
import org.apache.activemq.broker.ConnectionContext;
|
||||||
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.broker.region.Subscription;
|
||||||
import org.apache.activemq.broker.region.Topic;
|
import org.apache.activemq.broker.region.Topic;
|
||||||
import org.apache.activemq.command.Message;
|
import org.apache.activemq.command.Message;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
import org.apache.activemq.usage.SystemUsage;
|
import org.apache.activemq.usage.SystemUsage;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@ -53,16 +53,19 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor {
|
|||||||
private final Subscription subscription;
|
private final Subscription subscription;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param broker
|
||||||
* @param topic
|
* @param topic
|
||||||
* @param clientId
|
* @param clientId
|
||||||
* @param subscriberName
|
* @param subscriberName
|
||||||
|
* @param maxBatchSize
|
||||||
|
* @param subscription
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public StoreDurableSubscriberCursor(String clientId, String subscriberName, Store store, int maxBatchSize, Subscription subscription) {
|
public StoreDurableSubscriberCursor(Broker broker,String clientId, String subscriberName,int maxBatchSize, Subscription subscription) {
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.subscriberName = subscriberName;
|
this.subscriberName = subscriberName;
|
||||||
this.subscription = subscription;
|
this.subscription = subscription;
|
||||||
this.nonPersistent = new FilePendingMessageCursor(clientId + subscriberName, store);
|
this.nonPersistent = new FilePendingMessageCursor(broker,clientId + subscriberName);
|
||||||
storePrefetches.add(nonPersistent);
|
storePrefetches.add(nonPersistent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package org.apache.activemq.broker.region.cursors;
|
package org.apache.activemq.broker.region.cursors;
|
||||||
|
|
||||||
import org.apache.activemq.ActiveMQMessageAudit;
|
import org.apache.activemq.ActiveMQMessageAudit;
|
||||||
|
import org.apache.activemq.broker.Broker;
|
||||||
import org.apache.activemq.broker.region.MessageReference;
|
import org.apache.activemq.broker.region.MessageReference;
|
||||||
import org.apache.activemq.broker.region.Queue;
|
import org.apache.activemq.broker.region.Queue;
|
||||||
import org.apache.activemq.command.Message;
|
import org.apache.activemq.command.Message;
|
||||||
@ -33,9 +34,9 @@ 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 int pendingCount;
|
private int pendingCount;
|
||||||
private Queue queue;
|
private Queue queue;
|
||||||
private Store tmpStore;
|
|
||||||
private PendingMessageCursor nonPersistent;
|
private PendingMessageCursor nonPersistent;
|
||||||
private QueueStorePrefetch persistent;
|
private QueueStorePrefetch persistent;
|
||||||
private boolean started;
|
private boolean started;
|
||||||
@ -47,9 +48,9 @@ public class StoreQueueCursor extends AbstractPendingMessageCursor {
|
|||||||
* @param queue
|
* @param queue
|
||||||
* @param tmpStore
|
* @param tmpStore
|
||||||
*/
|
*/
|
||||||
public StoreQueueCursor(Queue queue, Store tmpStore) {
|
public StoreQueueCursor(Broker broker,Queue queue) {
|
||||||
|
this.broker=broker;
|
||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
this.tmpStore = tmpStore;
|
|
||||||
this.persistent = new QueueStorePrefetch(queue);
|
this.persistent = new QueueStorePrefetch(queue);
|
||||||
currentCursor = persistent;
|
currentCursor = persistent;
|
||||||
}
|
}
|
||||||
@ -58,7 +59,7 @@ public class StoreQueueCursor extends AbstractPendingMessageCursor {
|
|||||||
started = true;
|
started = true;
|
||||||
super.start();
|
super.start();
|
||||||
if (nonPersistent == null) {
|
if (nonPersistent == null) {
|
||||||
nonPersistent = new FilePendingMessageCursor(queue.getDestination(), tmpStore);
|
nonPersistent = new FilePendingMessageCursor(broker,queue.getName());
|
||||||
nonPersistent.setMaxBatchSize(getMaxBatchSize());
|
nonPersistent.setMaxBatchSize(getMaxBatchSize());
|
||||||
nonPersistent.setSystemUsage(systemUsage);
|
nonPersistent.setSystemUsage(systemUsage);
|
||||||
nonPersistent.setEnableAudit(isEnableAudit());
|
nonPersistent.setEnableAudit(isEnableAudit());
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
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.region.Subscription;
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
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;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a PendIngMessageCursor for Durable subscribers *
|
* Creates a PendIngMessageCursor for Durable subscribers *
|
||||||
@ -33,14 +33,15 @@ public class FilePendingDurableSubscriberMessageStoragePolicy implements Pending
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the configured pending message storage cursor;
|
* Retrieve the configured pending message storage cursor;
|
||||||
|
* @param broker
|
||||||
*
|
*
|
||||||
* @param clientId
|
* @param clientId
|
||||||
* @param name
|
* @param name
|
||||||
* @param tmpStorage
|
|
||||||
* @param maxBatchSize
|
* @param maxBatchSize
|
||||||
|
* @param sub
|
||||||
* @return the Pending Message cursor
|
* @return the Pending Message cursor
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getSubscriberPendingMessageCursor(String clientId, String name, Store tmpStorage, int maxBatchSize, Subscription sub) {
|
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String clientId, String name, int maxBatchSize, Subscription sub) {
|
||||||
return new FilePendingMessageCursor(name, tmpStorage);
|
return new FilePendingMessageCursor(broker,name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
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.region.Queue;
|
import org.apache.activemq.broker.region.Queue;
|
||||||
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;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a FilePendingMessageCursor *
|
* Creates a FilePendingMessageCursor *
|
||||||
@ -32,14 +32,14 @@ import org.apache.activemq.kaha.Store;
|
|||||||
public class FilePendingQueueMessageStoragePolicy implements PendingQueueMessageStoragePolicy {
|
public class FilePendingQueueMessageStoragePolicy implements PendingQueueMessageStoragePolicy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param broker
|
||||||
* @param queue
|
* @param queue
|
||||||
* @param tmpStore
|
|
||||||
* @return the cursor
|
* @return the cursor
|
||||||
* @see org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy#getQueuePendingMessageCursor(org.apache.openjpa.lib.util.concurrent.Queue,
|
* @see org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy#getQueuePendingMessageCursor(org.apache.openjpa.lib.util.concurrent.Queue,
|
||||||
* org.apache.activemq.kaha.Store)
|
* org.apache.activemq.kaha.Store)
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getQueuePendingMessageCursor(Queue queue, Store tmpStore) {
|
public PendingMessageCursor getQueuePendingMessageCursor(Broker broker,Queue queue) {
|
||||||
return new FilePendingMessageCursor("PendingCursor:" + queue.getName(), tmpStore);
|
return new FilePendingMessageCursor(broker,"PendingCursor:" + queue.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
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.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;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a PendIngMessageCursor for Durable subscribers *
|
* Creates a PendIngMessageCursor for Durable subscribers *
|
||||||
@ -31,15 +31,14 @@ import org.apache.activemq.kaha.Store;
|
|||||||
public class FilePendingSubscriberMessageStoragePolicy implements PendingSubscriberMessageStoragePolicy {
|
public class FilePendingSubscriberMessageStoragePolicy implements PendingSubscriberMessageStoragePolicy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param broker
|
||||||
* @param name
|
* @param name
|
||||||
* @param tmpStorage
|
|
||||||
* @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(String name, Store tmpStorage,
|
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String name,int maxBatchSize) {
|
||||||
int maxBatchSize) {
|
return new FilePendingMessageCursor(broker,"PendingCursor:" + name);
|
||||||
return new FilePendingMessageCursor("PendingCursor:" + name, tmpStorage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
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.region.Subscription;
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstraction to allow different policies for holding messages awaiting
|
* Abstraction to allow different policies for holding messages awaiting
|
||||||
@ -30,12 +30,13 @@ public interface PendingDurableSubscriberMessageStoragePolicy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the configured pending message storage cursor;
|
* Retrieve the configured pending message storage cursor;
|
||||||
|
* @param broker
|
||||||
*
|
*
|
||||||
* @param clientId
|
* @param clientId
|
||||||
* @param name
|
* @param name
|
||||||
* @param tmpStorage
|
|
||||||
* @param maxBatchSize
|
* @param maxBatchSize
|
||||||
|
* @param sub
|
||||||
* @return the Pending Message cursor
|
* @return the Pending Message cursor
|
||||||
*/
|
*/
|
||||||
PendingMessageCursor getSubscriberPendingMessageCursor(String clientId, String name, Store tmpStorage, int maxBatchSize, Subscription sub);
|
PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String clientId, String name, int maxBatchSize, Subscription sub);
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
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.region.Queue;
|
import org.apache.activemq.broker.region.Queue;
|
||||||
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstraction to allow different policies for holding messages awaiting
|
* Abstraction to allow different policies for holding messages awaiting
|
||||||
@ -30,10 +30,10 @@ public interface PendingQueueMessageStoragePolicy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the configured pending message storage cursor;
|
* Retrieve the configured pending message storage cursor;
|
||||||
|
* @param broker
|
||||||
*
|
*
|
||||||
* @param queue
|
* @param queue
|
||||||
* @param tmpStore
|
|
||||||
* @return the cursor
|
* @return the cursor
|
||||||
*/
|
*/
|
||||||
PendingMessageCursor getQueuePendingMessageCursor(Queue queue, Store tmpStore);
|
PendingMessageCursor getQueuePendingMessageCursor(Broker broker,Queue queue);
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,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.region.cursors.PendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstraction to allow different policies for holding messages awaiting
|
* Abstraction to allow different policies for holding messages awaiting
|
||||||
@ -29,11 +29,11 @@ public interface PendingSubscriberMessageStoragePolicy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the configured pending message storage cursor;
|
* Retrieve the configured pending message storage cursor;
|
||||||
|
* @param broker
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param tmpStorage
|
|
||||||
* @param maxBatchSize
|
* @param maxBatchSize
|
||||||
* @return the Pending Message cursor
|
* @return the Pending Message cursor
|
||||||
*/
|
*/
|
||||||
PendingMessageCursor getSubscriberPendingMessageCursor(String name, Store tmpStorage, int maxBatchSize);
|
PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String name,int maxBatchSize);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
|||||||
import org.apache.activemq.broker.region.group.MessageGroupHashBucketFactory;
|
import org.apache.activemq.broker.region.group.MessageGroupHashBucketFactory;
|
||||||
import org.apache.activemq.broker.region.group.MessageGroupMapFactory;
|
import org.apache.activemq.broker.region.group.MessageGroupMapFactory;
|
||||||
import org.apache.activemq.filter.DestinationMapEntry;
|
import org.apache.activemq.filter.DestinationMapEntry;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
import org.apache.activemq.usage.SystemUsage;
|
import org.apache.activemq.usage.SystemUsage;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@ -58,7 +57,7 @@ public class PolicyEntry extends DestinationMapEntry {
|
|||||||
private boolean producerFlowControl = true;
|
private boolean producerFlowControl = true;
|
||||||
private boolean optimizedDispatch=false;
|
private boolean optimizedDispatch=false;
|
||||||
|
|
||||||
public void configure(Queue queue, Store tmpStore) {
|
public void configure(Broker broker,Queue queue) {
|
||||||
if (dispatchPolicy != null) {
|
if (dispatchPolicy != null) {
|
||||||
queue.setDispatchPolicy(dispatchPolicy);
|
queue.setDispatchPolicy(dispatchPolicy);
|
||||||
}
|
}
|
||||||
@ -70,7 +69,7 @@ public class PolicyEntry extends DestinationMapEntry {
|
|||||||
queue.getMemoryUsage().setLimit(memoryLimit);
|
queue.getMemoryUsage().setLimit(memoryLimit);
|
||||||
}
|
}
|
||||||
if (pendingQueuePolicy != null) {
|
if (pendingQueuePolicy != null) {
|
||||||
PendingMessageCursor messages = pendingQueuePolicy.getQueuePendingMessageCursor(queue, tmpStore);
|
PendingMessageCursor messages = pendingQueuePolicy.getQueuePendingMessageCursor(broker,queue);
|
||||||
queue.setMessages(messages);
|
queue.setMessages(messages);
|
||||||
}
|
}
|
||||||
queue.setProducerFlowControl(isProducerFlowControl());
|
queue.setProducerFlowControl(isProducerFlowControl());
|
||||||
@ -121,16 +120,16 @@ 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(name, broker.getTempDataStore(), maxBatchSize));
|
subscription.setMatched(pendingSubscriberPolicy.getSubscriberPendingMessageCursor(broker,name, maxBatchSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configure(Broker broker, SystemUsage memoryManager, DurableTopicSubscription sub) {
|
public void configure(Broker broker, SystemUsage memoryManager, DurableTopicSubscription sub) {
|
||||||
String clientId = sub.getClientId();
|
String clientId = sub.getSubscriptionKey().getClientId();
|
||||||
String subName = sub.getSubscriptionName();
|
String subName = sub.getSubscriptionKey().getSubscriptionName();
|
||||||
int prefetch = sub.getPrefetchSize();
|
int prefetch = sub.getPrefetchSize();
|
||||||
if (pendingDurableSubscriberPolicy != null) {
|
if (pendingDurableSubscriberPolicy != null) {
|
||||||
PendingMessageCursor cursor = pendingDurableSubscriberPolicy.getSubscriberPendingMessageCursor(clientId, subName, broker.getTempDataStore(), prefetch, sub);
|
PendingMessageCursor cursor = pendingDurableSubscriberPolicy.getSubscriberPendingMessageCursor(broker,clientId, subName,prefetch,sub);
|
||||||
cursor.setSystemUsage(memoryManager);
|
cursor.setSystemUsage(memoryManager);
|
||||||
sub.setPending(cursor);
|
sub.setPending(cursor);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,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.region.Subscription;
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
import org.apache.activemq.broker.region.cursors.StoreDurableSubscriberCursor;
|
import org.apache.activemq.broker.region.cursors.StoreDurableSubscriberCursor;
|
||||||
@ -34,14 +35,15 @@ public class StorePendingDurableSubscriberMessageStoragePolicy implements Pendin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the configured pending message storage cursor;
|
* Retrieve the configured pending message storage cursor;
|
||||||
|
* @param broker
|
||||||
*
|
*
|
||||||
* @param clientId
|
* @param clientId
|
||||||
* @param name
|
* @param name
|
||||||
* @param tmpStorage
|
|
||||||
* @param maxBatchSize
|
* @param maxBatchSize
|
||||||
|
* @param sub
|
||||||
* @return the Pending Message cursor
|
* @return the Pending Message cursor
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getSubscriberPendingMessageCursor(String clientId, String name, Store tmpStorage, int maxBatchSize, Subscription sub) {
|
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String clientId, String name, int maxBatchSize, Subscription sub) {
|
||||||
return new StoreDurableSubscriberCursor(clientId, name, tmpStorage, maxBatchSize, sub);
|
return new StoreDurableSubscriberCursor(broker,clientId, name, maxBatchSize, sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
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.region.Queue;
|
import org.apache.activemq.broker.region.Queue;
|
||||||
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
|
||||||
import org.apache.activemq.broker.region.cursors.StoreQueueCursor;
|
import org.apache.activemq.broker.region.cursors.StoreQueueCursor;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a StoreQueueCursor *
|
* Creates a StoreQueueCursor *
|
||||||
@ -32,14 +32,14 @@ import org.apache.activemq.kaha.Store;
|
|||||||
public class StorePendingQueueMessageStoragePolicy implements PendingQueueMessageStoragePolicy {
|
public class StorePendingQueueMessageStoragePolicy implements PendingQueueMessageStoragePolicy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param broker
|
||||||
* @param queue
|
* @param queue
|
||||||
* @param tmpStore
|
|
||||||
* @return the cursor
|
* @return the cursor
|
||||||
* @see org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy#getQueuePendingMessageCursor(org.apache.openjpa.lib.util.concurrent.Queue,
|
* @see org.apache.activemq.broker.region.policy.PendingQueueMessageStoragePolicy#getQueuePendingMessageCursor(org.apache.openjpa.lib.util.concurrent.Queue,
|
||||||
* org.apache.activemq.kaha.Store)
|
* org.apache.activemq.kaha.Store)
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getQueuePendingMessageCursor(Queue queue, Store tmpStore) {
|
public PendingMessageCursor getQueuePendingMessageCursor(Broker broker,Queue queue) {
|
||||||
return new StoreQueueCursor(queue, tmpStore);
|
return new StoreQueueCursor(broker,queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
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.region.Subscription;
|
import org.apache.activemq.broker.region.Subscription;
|
||||||
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;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a VMPendingMessageCursor *
|
* Creates a VMPendingMessageCursor *
|
||||||
@ -32,14 +32,14 @@ public class VMPendingDurableSubscriberMessageStoragePolicy implements PendingDu
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the configured pending message storage cursor;
|
* Retrieve the configured pending message storage cursor;
|
||||||
*
|
* @param broker
|
||||||
* @param clientId
|
* @param clientId
|
||||||
* @param name
|
* @param name
|
||||||
* @param tmpStorage
|
|
||||||
* @param maxBatchSize
|
* @param maxBatchSize
|
||||||
|
* @param sub
|
||||||
* @return the Pending Message cursor
|
* @return the Pending Message cursor
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getSubscriberPendingMessageCursor(String clientId, String name, Store tmpStorage, int maxBatchSize, Subscription sub) {
|
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String clientId, String name,int maxBatchSize, Subscription sub) {
|
||||||
return new VMPendingMessageCursor();
|
return new VMPendingMessageCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
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.region.Queue;
|
import org.apache.activemq.broker.region.Queue;
|
||||||
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;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a VMPendingMessageCursor *
|
* Creates a VMPendingMessageCursor *
|
||||||
@ -32,11 +32,11 @@ import org.apache.activemq.kaha.Store;
|
|||||||
public class VMPendingQueueMessageStoragePolicy implements PendingQueueMessageStoragePolicy {
|
public class VMPendingQueueMessageStoragePolicy implements PendingQueueMessageStoragePolicy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param broker
|
||||||
* @param queue
|
* @param queue
|
||||||
* @param tmpStore
|
|
||||||
* @return the cursor
|
* @return the cursor
|
||||||
*/
|
*/
|
||||||
public PendingMessageCursor getQueuePendingMessageCursor(Queue queue, Store tmpStore) {
|
public PendingMessageCursor getQueuePendingMessageCursor(Broker broker,Queue queue) {
|
||||||
return new VMPendingMessageCursor();
|
return new VMPendingMessageCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
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.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;
|
||||||
import org.apache.activemq.kaha.Store;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a VMPendingMessageCursor *
|
* Creates a VMPendingMessageCursor *
|
||||||
@ -31,15 +31,14 @@ import org.apache.activemq.kaha.Store;
|
|||||||
public class VMPendingSubscriberMessageStoragePolicy implements PendingSubscriberMessageStoragePolicy {
|
public class VMPendingSubscriberMessageStoragePolicy implements PendingSubscriberMessageStoragePolicy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param broker
|
||||||
* @param name
|
* @param name
|
||||||
* @param tmpStorage
|
|
||||||
* @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(String name, Store tmpStorage,
|
public PendingMessageCursor getSubscriberPendingMessageCursor(Broker broker,String name,int maxBatchSize) {
|
||||||
int maxBatchSize) {
|
|
||||||
return new VMPendingMessageCursor();
|
return new VMPendingMessageCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user