public synchronized void purge() throws Exception { final long originalMessageCount = destination.getDestinationStatistics().getMessages().getCount(); ((Queue)destination).purge(); LOG.info("{} purge of {} messages", destination.getActiveMQDestination().getQualifiedName(), originalMessageCount); }
Queue queue = new TempQueue(brokerService, destination, null, destinationStatistics, taskRunnerFactory); configureQueue(queue, destination); queue.initialize(); return queue; } else { MessageStore store = persistenceAdapter.createQueueMessageStore((ActiveMQQueue)destination); Queue queue = new Queue(brokerService, destination, store, destinationStatistics, taskRunnerFactory); configureQueue(queue, destination); queue.initialize(); return queue;
acknowledge(context, sub, ack, reference); dropMessage(reference); } else { try { acknowledge(context, sub, ack, reference); } finally { context.getTransaction().addSynchronization(new Synchronization() { getDestinationStatistics().getForwards().increment();
@Override public void wakeup() { if (optimizedDispatch && !iterationRunning) { iterate(); pendingWakeups.incrementAndGet(); } else { asyncWakeup(); } }
private void expireMessages() { LOG.debug("{} expiring messages ..", getActiveMQDestination().getQualifiedName()); // just track the insertion count List<Message> browsedMessages = new InsertionCountList<Message>(); doBrowse(browsedMessages, this.getMaxExpirePageSize()); asyncWakeup(); LOG.debug("{} expiring messages done.", getActiveMQDestination().getQualifiedName()); }
protected void doBrowseList(List<Message> browseList, int max, PendingList list, ReentrantReadWriteLock lock, ConnectionContext connectionContext, String name) throws Exception { List<MessageReference> toExpire = new ArrayList<MessageReference>(); lock.readLock().lock(); try { addAll(list.values(), browseList, max, toExpire); } finally { lock.readLock().unlock(); } for (MessageReference ref : toExpire) { if (broker.isExpired(ref)) { LOG.debug("expiring from {}: {}", name, ref); messageExpired(connectionContext, ref); } else { lock.writeLock().lock(); try { list.remove(ref); } finally { lock.writeLock().unlock(); } ref.decrementReferenceCount(); } } }
@Override public void addSubscription(ConnectionContext context, Subscription sub) throws Exception { LOG.debug("{} add sub: {}, dequeues: {}, dispatched: {}, inflight: {}", new Object[]{ getActiveMQDestination().getQualifiedName(), sub, getDestinationStatistics().getDequeues().getCount(), getDestinationStatistics().getDispatched().getCount(), getDestinationStatistics().getInflight().getCount() }); addToConsumerList(sub); if (sub.getConsumerInfo().isExclusive() || isAllConsumersExclusiveByDefault()) { Subscription exclusiveConsumer = dispatchSelector.getExclusiveConsumer(); if (exclusiveConsumer == null) { wakeup(); wakeup();
pendingSends.incrementAndGet(); do { checkUsage(context, producerExchange, message); message.getMessageId().setBrokerSequenceId(getDestinationSequenceId()); if (store != null && message.isPersistent()) { message.getMessageId().setFutureOrSequenceLong(null); if (messages.isCacheEnabled() && !isPersistJMSRedelivered()) { result = store.asyncAddQueueMessage(context, message, isOptimizeStorage()); result.addListener(new PendingMarshalUsageTracker(message)); } else { rollbackPendingCursorAdditions(message.getMessageId()); throw e; if (isReduceMemoryFootprint() && message.isMarshalled()) { message.clearUnMarshalledState(); if(tryOrderedCursorAdd(message, context)) { break;
public void doBrowse(List<Message> browseList, int max) { final ConnectionContext connectionContext = createConnectionContext(); try { pageInMessages(false); List<MessageReference> toExpire = new ArrayList<MessageReference>(); addAll(pagedInPendingDispatch, browseList, max, toExpire); for (MessageReference ref : toExpire) { pagedInPendingDispatch.remove(ref); if (broker.isExpired(ref)) { LOG.debug("expiring from pagedInPending: " + ref); messageExpired(connectionContext, ref); pagedInMessagesLock.readLock().lock(); try { addAll(pagedInMessages.values(), browseList, max, toExpire); } finally { pagedInMessagesLock.readLock().unlock(); if (broker.isExpired(ref)) { LOG.debug("expiring from pagedInMessages: " + ref); messageExpired(connectionContext, ref); } else { pagedInMessagesLock.writeLock().lock(); if (browseList.size() < getMaxBrowsePageSize()) { messagesLock.writeLock().lock(); try { if (broker.isExpired(node)) {
if (isPrioritizedMessages() && !dispatchPendingList.isEmpty() && list != null && !list.isEmpty()) { doActualDispatch(dispatchPendingList); dispatchPendingList.addAll(doActualDispatch(list)); } else { for (MessageReference qmr : list) { asyncWakeup();
if (dispatchSelector.canSelect(s, node) && assignMessageGroup(s, (QueueMessageReference)node) && !((QueueMessageReference) node).isAcked() ) { consumersLock.writeLock().lock(); try { if (removeFromConsumerList(target)) { addToConsumerList(target); consumers = new ArrayList<Subscription>(this.consumers);
Future<Object> result = null; checkUsage(context, message); sendLock.lockInterruptibly(); try { if (store != null && message.isPersistent()) { message.getMessageId().setBrokerSequenceId(getDestinationSequenceId()); if (messages.isCacheEnabled()) { result = store.asyncAddQueueMessage(context, message); store.addMessage(context, message); if (isReduceMemoryFootprint()) { message.clearMarshalledState(); sendMessage(message); messageSent(context, message);
if (groupId != null) { MessageGroupMap messageGroupOwners = getMessageGroupOwners(); assignGroup(subscription, messageGroupOwners, node, groupId); } else { assignGroup(subscription, messageGroupOwners, node, groupId); } else { if (groupOwner.equals(subscription.getConsumerInfo().getConsumerId())) {
consumersLock.writeLock().lock(); try { if (this.consumers.isEmpty() || isSlave()) { if (!fullConsumers.contains(s)) { if (!s.isFull()) { if (assignMessageGroup(s, (QueueMessageReference)node)) { consumersLock.writeLock().lock(); try { if (removeFromConsumerList(target)) { addToConsumerList(target); consumers = new ArrayList<Subscription>(this.consumers);
public void wakeup() { if (optimizedDispatch || isSlave()) { iterate(); pendingWakeups.incrementAndGet(); } else { asyncWakeup(); } }
@Override public void onUsageChanged(@SuppressWarnings("rawtypes") Usage usage, int oldPercentUsage, int newPercentUsage) { if (oldPercentUsage > newPercentUsage) { asyncWakeup(); } }
redeliveredWaitingDispatch = doActualDispatch(redeliveredWaitingDispatch); pagedInPendingDispatch = doActualDispatch(pagedInPendingDispatch); pagedInPendingDispatch.addAll(doActualDispatch(list)); } else { for (QueueMessageReference qmr : list) { asyncWakeup();
@Override public void addSubscription(ConnectionContext context, Subscription sub) throws Exception { // Only consumers on the same connection can consume from // the temporary destination // However, we could have failed over - and we do this // check client side anyways .... if (!context.isFaultTolerant() && (!context.isNetworkConnection() && !tempDest .getConnectionId().equals( sub.getConsumerInfo().getConsumerId() .getConnectionId()))) { tempDest.setConnectionId(sub.getConsumerInfo().getConsumerId().getConnectionId()); LOG.debug("changed ownership of {} to {}", this, tempDest.getConnectionId()); } super.addSubscription(context, sub); }
@Override public void addSubscription(ConnectionContext context, Subscription sub) throws Exception { LOG.debug("{} add sub: {}, dequeues: {}, dispatched: {}, inflight: {}", new Object[]{ getActiveMQDestination().getQualifiedName(), sub, getDestinationStatistics().getDequeues().getCount(), getDestinationStatistics().getDispatched().getCount(), getDestinationStatistics().getInflight().getCount() }); addToConsumerList(sub); if (sub.getConsumerInfo().isExclusive() || isAllConsumersExclusiveByDefault()) { Subscription exclusiveConsumer = dispatchSelector.getExclusiveConsumer(); if (exclusiveConsumer == null) { wakeup(); wakeup();
pendingSends.incrementAndGet(); do { checkUsage(context, producerExchange, message); message.getMessageId().setBrokerSequenceId(getDestinationSequenceId()); if (store != null && message.isPersistent()) { message.getMessageId().setFutureOrSequenceLong(null); if (messages.isCacheEnabled() && !isPersistJMSRedelivered()) { result = store.asyncAddQueueMessage(context, message, isOptimizeStorage()); result.addListener(new PendingMarshalUsageTracker(message)); } else { if (isReduceMemoryFootprint() && message.isMarshalled()) { message.clearUnMarshalledState(); if(tryOrderedCursorAdd(message, context)) { break;