public boolean add(ConnectionContext context, MessageReference node) throws Exception { final Message message = node.getMessage(); final Object retainValue = message.getProperty(RETAIN_PROPERTY); // retain property set to true final boolean retain = retainValue != null && Boolean.parseBoolean(retainValue.toString()); if (retain) { if (message.getContent().getLength() > 0) { // non zero length message content retainedMessage = message.copy(); retainedMessage.getMessage().removeProperty(RETAIN_PROPERTY); retainedMessage.getMessage().setProperty(RETAINED_PROPERTY, true); } else { // clear retained message retainedMessage = null; } // TODO should we remove the publisher's retain property?? node.getMessage().removeProperty(RETAIN_PROPERTY); } return wrapped == null ? true : wrapped.add(context, node); }
public Message[] browse(ActiveMQDestination destination) throws Exception { final List<Message> result = new ArrayList<Message>(); if (retainedMessage != null) { DestinationFilter filter = DestinationFilter.parseFilter(destination); if (filter.matches(retainedMessage.getMessage().getDestination())) { result.add(retainedMessage.getMessage()); } } Message[] messages = result.toArray(new Message[result.size()]); if (wrapped != null) { final Message[] wrappedMessages = wrapped.browse(destination); if (wrappedMessages != null && wrappedMessages.length > 0) { final int origLen = messages.length; messages = Arrays.copyOf(messages, origLen + wrappedMessages.length); System.arraycopy(wrappedMessages, 0, messages, origLen, wrappedMessages.length); } } return messages; }
public void configure(Broker broker,Topic topic) { baseConfiguration(broker,topic); if (dispatchPolicy != null) { topic.setDispatchPolicy(dispatchPolicy); } topic.setDeadLetterStrategy(getDeadLetterStrategy()); if (subscriptionRecoveryPolicy != null) { SubscriptionRecoveryPolicy srp = subscriptionRecoveryPolicy.copy(); srp.setBroker(broker); topic.setSubscriptionRecoveryPolicy(srp); } if (memoryLimit > 0) { topic.getMemoryUsage().setLimit(memoryLimit); } topic.setLazyDispatch(isLazyDispatch()); }
public void recoverRetroactiveMessages(ConnectionContext context, Subscription subscription) throws Exception { if (subscription.getConsumerInfo().isRetroactive()) { subscriptionRecoveryPolicy.recover(context, this, subscription); } }
public void stop() throws Exception { if (wrapped != null) { wrapped.stop(); } }
public void start() throws Exception { if (wrapped != null) { wrapped.start(); } }
public void recover(ConnectionContext context, Topic topic, SubscriptionRecovery sub) throws Exception { // Re-dispatch the last retained message seen. if (retainedMessage != null) { sub.addRecoveredMessage(context, retainedMessage); } if (wrapped != null) { // retain default ActiveMQ behaviour of recovering messages only for empty durable subscriptions boolean recover = true; if (sub instanceof DurableTopicSubscription && !((DurableTopicSubscription)sub).isEmpty(topic)) { recover = false; } if (recover) { wrapped.recover(context, topic, sub); } } }
@Override public void stop() throws Exception { if (started.compareAndSet(true, false)) { if (taskRunner != null) { taskRunner.shutdown(); } this.subscriptionRecoveryPolicy.stop(); if (memoryUsage != null) { memoryUsage.stop(); } if (this.topicStore != null) { this.topicStore.stop(); } scheduler.cancel(expireMessagesTask); } }
@Override public void start() throws Exception { if (started.compareAndSet(false, true)) { this.subscriptionRecoveryPolicy.start(); if (memoryUsage != null) { memoryUsage.start(); } if (getExpireMessagesPeriod() > 0 && !AdvisorySupport.isAdvisoryTopic(getActiveMQDestination())) { scheduler.executePeriodically(expireMessagesTask, getExpireMessagesPeriod()); } } }
public void configure(Broker broker,Topic topic) { baseConfiguration(broker,topic); if (dispatchPolicy != null) { topic.setDispatchPolicy(dispatchPolicy); } topic.setDeadLetterStrategy(getDeadLetterStrategy()); if (subscriptionRecoveryPolicy != null) { SubscriptionRecoveryPolicy srp = subscriptionRecoveryPolicy.copy(); srp.setBroker(broker); topic.setSubscriptionRecoveryPolicy(srp); } if (memoryLimit > 0) { topic.getMemoryUsage().setLimit(memoryLimit); } topic.setLazyDispatch(isLazyDispatch()); }
subscriptionRecoveryPolicy.recover(context, this, sub);
Message[] msgs = subscriptionRecoveryPolicy.browse(getActiveMQDestination()); if (msgs != null) { for (int i = 0; i < msgs.length && browseList.size() < max; i++) {
public void stop() throws Exception { if (wrapped != null) { wrapped.stop(); } }
public void start() throws Exception { if (wrapped != null) { wrapped.start(); } }
if (!subscriptionRecoveryPolicy.add(context, message)) { return;
public void configure(Broker broker,Topic topic) { baseConfiguration(broker,topic); if (dispatchPolicy != null) { topic.setDispatchPolicy(dispatchPolicy); } topic.setDeadLetterStrategy(getDeadLetterStrategy()); if (subscriptionRecoveryPolicy != null) { SubscriptionRecoveryPolicy srp = subscriptionRecoveryPolicy.copy(); srp.setBroker(broker); topic.setSubscriptionRecoveryPolicy(srp); } if (memoryLimit > 0) { topic.getMemoryUsage().setLimit(memoryLimit); } topic.setLazyDispatch(isLazyDispatch()); }
public void recoverRetroactiveMessages(ConnectionContext context, Subscription subscription) throws Exception { if (subscription.getConsumerInfo().isRetroactive()) { subscriptionRecoveryPolicy.recover(context, this, subscription); } }
if (topic != null) { final Message[] messages = topic.getSubscriptionRecoveryPolicy().browse(topic.getActiveMQDestination());
public void stop() throws Exception { if (wrapped != null) { wrapped.stop(); } }
public void start() throws Exception { if (wrapped != null) { wrapped.start(); } }