Topic topic = (Topic) destination; add(context, topic); topic.activate(context, this); if (topic.isAlwaysRetroactive() || info.isRetroactive()) { topic.recoverRetroactiveMessages(context, this);
Topic topic = new Topic(brokerService, destination, null, destinationStatistics, taskRunnerFactory); configureTopic(topic, destination); topic.initialize(); return topic; } else { store = persistenceAdapter.createTopicMessageStore((ActiveMQTopic)destination); Topic topic = new Topic(brokerService, destination, store, destinationStatistics, taskRunnerFactory); configureTopic(topic, destination); topic.initialize(); return topic;
@Override public void messageExpired(ConnectionContext context, Subscription subs, MessageReference reference) { broker.messageExpired(context, reference, subs); // AMQ-2586: Better to leave this stat at zero than to give the user // misleading metrics. // destinationStatistics.getMessages().decrement(); destinationStatistics.getExpired().increment(); MessageAck ack = new MessageAck(); ack.setAckType(MessageAck.STANDARD_ACK_TYPE); ack.setDestination(destination); ack.setMessageID(reference.getMessageId()); try { if (subs instanceof DurableTopicSubscription) { ((DurableTopicSubscription)subs).removePending(reference); } acknowledge(context, subs, ack, reference); } catch (Exception e) { LOG.error("Failed to remove expired Message from the store ", e); } }
@Override public void afterCommit() throws Exception { // It could take while before we receive the commit // operation.. by that time the message could have // expired.. if (message.isExpired()) { if (broker.isExpired(message)) { getDestinationStatistics().getExpired().increment(); broker.messageExpired(context, message, null); } message.decrementReferenceCount(); return; } try { dispatch(context, message); } finally { message.decrementReferenceCount(); } }
throws IOException, Exception { final ConnectionContext context = producerExchange.getConnectionContext(); message.getMessageId().setBrokerSequenceId(getDestinationSequenceId()); Future<Object> result = null; if (topicStore != null && message.isPersistent() && !canOptimizeOutPersistence()) { if (systemUsage.getStoreUsage().isFull(getStoreUsageHighWaterMark())) { final String logMessage = "Persistent store is Full, " + getStoreUsageHighWaterMark() + "% of " + systemUsage.getStoreUsage().getLimit() + ". Stopping producer (" + message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info"; if (!context.isNetworkConnection() && systemUsage.isSendFailIfNoSpace()) { waitForSpace(context,producerExchange, systemUsage.getStoreUsage(), getStoreUsageHighWaterMark(), logMessage); result = topicStore.asyncAddTopicMessage(context, message,isOptimizeStorage()); dispatch(context, message); } finally { message.decrementReferenceCount();
getDestinationStatistics().getExpired().increment(); if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message.getSize()); isFull(context, memoryUsage); fastProducer(context, producerInfo); if (isProducerFlowControl() && context.isProducerFlowControl()) { if (isFlowControlLogRequired()) { LOG.warn("{}, Usage Manager memory limit reached {}. Producers will be throttled to the rate at which messages are removed from this destination to prevent flooding it. See http://activemq.apache.org/producer-flow-control.html for more info.", getActiveMQDestination().getQualifiedName(), memoryUsage.getLimit()); } else { LOG.debug("{}, Usage Manager memory limit reached {}. Producers will be throttled to the rate at which messages are removed from this destination to prevent flooding it. See http://activemq.apache.org/producer-flow-control.html for more info.", getActiveMQDestination().getQualifiedName(), memoryUsage.getLimit()); throw new javax.jms.ResourceAllocationException("Usage Manager memory limit (" + memoryUsage.getLimit() + ") reached. Rejecting send for producer (" + message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info"); registerCallbackForNotFullNotification(); context.setDontSendReponse(true); return; waitForSpace( context, producerExchange,
@Override public void run() { try { // While waiting for space to free up... the // message may have expired. if (message.isExpired()) { broker.messageExpired(context, message, null); getDestinationStatistics().getExpired().increment(); } else { doMessageSend(producerExchange, message); } if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message .getSize()); context.getConnection().dispatchAsync(ack); } else { Response response = new Response(); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } } catch (Exception e) { if (!sendProducerAck && !context.isInRecoveryMode()) { ExceptionResponse response = new ExceptionResponse(e); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } } } });
topicsToDeactivate.add(topic); } else { topic.getDestinationStatistics().getInflight().subtract(dispatched.size()); topic.deactivate(context, this, savedDispateched);
public void deleteSubscription(ConnectionContext context, SubscriptionKey key) throws Exception { if (next instanceof DestinationFilter) { DestinationFilter filter = (DestinationFilter) next; filter.deleteSubscription(context, key); } else if (next instanceof Topic) { Topic topic = (Topic)next; topic.deleteSubscription(context, key); } }
Topic topic = (Topic) iter.next(); add(context, topic); topic.activate(context, this); .iterator(); iter.hasNext();) { Topic topic = (Topic) iter.next(); topic.recoverRetroactiveMessages(context, this);
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()); if (LOG.isDebugEnabled()) { LOG.debug(" changed ownership of " + this + " to "+ tempDest.getConnectionId()); } } super.addSubscription(context, sub); }
try { if (dest instanceof org.apache.activemq.broker.region.Topic) { ((org.apache.activemq.broker.region.Topic) dest).recoverRetroactiveMessages(connectionContext, subscription); } else if (dest instanceof VirtualTopicInterceptor) { ((VirtualTopicInterceptor) dest).getTopic().recoverRetroactiveMessages(connectionContext, subscription);
@Override public void add(ConnectionContext context, Destination destination) throws Exception { if (!destinations.contains(destination)) { super.add(context, destination); } // do it just once per destination if (durableDestinations.containsKey(destination.getActiveMQDestination())) { return; } durableDestinations.put(destination.getActiveMQDestination(), destination); if (active.get() || keepDurableSubsActive) { Topic topic = (Topic) destination; topic.activate(context, this); getSubscriptionStatistics().getEnqueues().add(pending.size()); } else if (destination.getMessageStore() != null) { TopicMessageStore store = (TopicMessageStore) destination.getMessageStore(); try { getSubscriptionStatistics().getEnqueues().add(store.getMessageCount(subscriptionKey.getClientId(), subscriptionKey.getSubscriptionName())); } catch (IOException e) { JMSException jmsEx = new JMSException("Failed to retrieve enqueueCount from store " + e); jmsEx.setLinkedException(e); throw jmsEx; } } dispatchPending(); }
for (Iterator<Destination> iter = destinations.values().iterator(); iter.hasNext();) { Topic topic = (Topic)iter.next(); topic.deactivate(context, this);
getDestinationStatistics().getExpired().increment(); if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message.getSize()); isFull(context, memoryUsage); fastProducer(context, producerInfo); if (isProducerFlowControl() && context.isProducerFlowControl()) { if (isFlowControlLogRequired()) { LOG.info("{}, Usage Manager memory limit reached {}. Producers will be throttled to the rate at which messages are removed from this destination to prevent flooding it. See http://activemq.apache.org/producer-flow-control.html for more info.", getActiveMQDestination().getQualifiedName(), memoryUsage.getLimit()); throw new javax.jms.ResourceAllocationException("Usage Manager memory limit (" + memoryUsage.getLimit() + ") reached. Rejecting send for producer (" + message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info"); registerCallbackForNotFullNotification(); context.setDontSendReponse(true); return; waitForSpace( context, producerExchange, + message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName()
throws IOException, Exception { final ConnectionContext context = producerExchange.getConnectionContext(); message.getMessageId().setBrokerSequenceId(getDestinationSequenceId()); Future<Object> result = null; if (topicStore != null && message.isPersistent() && !canOptimizeOutPersistence()) { if (systemUsage.getStoreUsage().isFull(getStoreUsageHighWaterMark())) { final String logMessage = "Persistent store is Full, " + getStoreUsageHighWaterMark() + "% of " + systemUsage.getStoreUsage().getLimit() + ". Stopping producer (" + message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info"; if (!context.isNetworkConnection() && systemUsage.isSendFailIfNoSpace()) { waitForSpace(context,producerExchange, systemUsage.getStoreUsage(), getStoreUsageHighWaterMark(), logMessage); result = topicStore.asyncAddTopicMessage(context, message,isOptimizeStorage()); dispatch(context, message); } finally { message.decrementReferenceCount();
@Override public void afterCommit() throws Exception { // It could take while before we receive the commit // operration.. by that time the message could have // expired.. if (broker.isExpired(message)) { getDestinationStatistics().getExpired().increment(); broker.messageExpired(context, message, null); message.decrementReferenceCount(); return; } try { dispatch(context, message); } finally { message.decrementReferenceCount(); } } });
@Override public void run() { try { // While waiting for space to free up... the // message may have expired. if (message.isExpired()) { broker.messageExpired(context, message, null); getDestinationStatistics().getExpired().increment(); } else { doMessageSend(producerExchange, message); } if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message .getSize()); context.getConnection().dispatchAsync(ack); } else { Response response = new Response(); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } } catch (Exception e) { if (!sendProducerAck && !context.isInRecoveryMode()) { ExceptionResponse response = new ExceptionResponse(e); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } } } });
topicsToDeactivate.add(topic); } else { topic.getDestinationStatistics().getInflight().subtract(dispatched.size()); topic.deactivate(context, this, savedDispateched);
if (dest instanceof Topic){ Topic topic = (Topic)dest; topic.deleteSubscription(context, key); } else if (dest instanceof DestinationFilter) { DestinationFilter filter = (DestinationFilter) dest;