Package org.apache.activemq.broker.region

Examples of org.apache.activemq.broker.region.Subscription


        this.redrawOnRemove = redrawOnRemove;
       
    }

    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
        Subscription answer = super.addConsumer(context, info);
        generateFile();
        return answer;
    }
View Full Code Here


    public boolean dispatch(MessageReference node,
            MessageEvaluationContext msgContext, List<Subscription> consumers)
            throws Exception {
        int count = 0;

        Subscription firstMatchingConsumer = null;
        synchronized (consumers) {
            for (Iterator<Subscription> iter = consumers.iterator(); iter
                    .hasNext();) {
                Subscription sub = iter.next();

                // Only dispatch to interested subscriptions
                if (!sub.matches(node, msgContext)) {
                    sub.unmatched(node);
                    continue;
                }

                if (firstMatchingConsumer == null) {
                    firstMatchingConsumer = sub;
                }

                sub.add(node);
                count++;
            }

            if (firstMatchingConsumer != null) {
                // Rotate the consumer list.
View Full Code Here

            for (Subscription sub: consumers) {
                ConsumerInfo info = sub.getConsumerInfo();
                if (info.isNetworkSubscription()) {   
                    boolean highestPrioritySub = true;
                    for (Iterator<Subscription> it =  duplicateFreeSubs.iterator(); it.hasNext(); ) {
                        Subscription candidate = it.next();
                        if (matches(candidate, info)) {
                            if (hasLowerPriority(candidate, info)) {
                                it.remove();
                            } else {
                                // higher priority matching sub exists
                                highestPrioritySub = false;
                                if (LOG.isDebugEnabled()) {
                                LOG.debug("ignoring lower priority: " + candidate
                                        + "[" +candidate.getConsumerInfo().getNetworkConsumerIds() +", "
                                        + candidate.getConsumerInfo().getNetworkConsumerIds() +"] in favour of: "
                                        + sub
                                        + "[" +sub.getConsumerInfo().getNetworkConsumerIds() +", "
                                        + sub.getConsumerInfo().getNetworkConsumerIds() +"]");
                                }
                            }
View Full Code Here

    }

    private ConsumerInfo getConsumerInfo(ConcurrentHashMap<SubscriptionKey, DurableTopicSubscription> durableSubscriptions) {
        ConsumerInfo info=null;
        for(Iterator<DurableTopicSubscription> it=durableSubscriptions.values().iterator();it.hasNext();){
            Subscription sub = it.next();
            info=sub.getConsumerInfo();
            if(info.getSubscriptionName().equals(PrefetchConsumer.SUBSCRIPTION_NAME)){
                return info;
            }
        }
        return null;
View Full Code Here

        super(broker, destinationStatistics, memoryManager, taskRunnerFactory, destinationFactory);
        this.regionBroker = broker;
    }

    protected Subscription createSubscription(ConnectionContext context, ConsumerInfo info) throws JMSException {
        Subscription sub = super.createSubscription(context, info);
        ObjectName name = regionBroker.registerSubscription(context, sub);
        sub.setObjectName(name);
        return sub;
    }
View Full Code Here

        }
        return rc;
    }

    public void abortConsumer(ObjectName consumerToAbort) {
        Subscription sub = broker.getSubscriber(consumerToAbort);
        if (sub != null) {
            LOG.info("aborting consumer via jmx: " + sub.getConsumerInfo().getConsumerId());          
            strategy.abortConsumer(sub, false);
        } else {
            LOG.warn("cannot resolve subscription matching name: " + consumerToAbort);
        }
View Full Code Here

        }

    }

    public void abortConnection(ObjectName consumerToAbort) {
        Subscription sub = broker.getSubscriber(consumerToAbort);
        if (sub != null) {
            LOG.info("aborting consumer connection via jmx: " + sub.getConsumerInfo().getConsumerId().getConnectionId());
            strategy.abortConsumer(sub, true);
        } else {
            LOG.warn("cannot resolve subscription matching name: " + consumerToAbort);
        }
    }
View Full Code Here

        connections.put(copy.getConnectionId(), copy);
    }

    @Override
    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
        Subscription answer = super.addConsumer(context, info);

        // Don't advise advisory topics.
        if (!AdvisorySupport.isAdvisoryTopic(info.getDestination())) {
            ActiveMQTopic topic = AdvisorySupport.getConsumerAdvisoryTopic(info.getDestination());
            consumers.offer(info);
View Full Code Here

        consumerId.setValue(0);
        info.setConsumerId(consumerId);
        info.setDestination(new ActiveMQTopic(topicName));
        info.setSubscriptionName(subscriberName);
        info.setSelector(selector);
        Subscription subscription = safeGetBroker().addConsumer(context, info);
        safeGetBroker().removeConsumer(context, info);
        if (subscription != null) {
            return subscription.getObjectName();
        }
        return null;
    }
View Full Code Here

        }
    }

    @Override
    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
        Subscription sub = super.addConsumer(context, info);
        SubscriptionKey subscriptionKey = new SubscriptionKey(sub.getContext().getClientId(), sub.getConsumerInfo().getSubscriptionName());
        ObjectName inactiveName = subscriptionKeys.get(subscriptionKey);
        if (inactiveName != null) {
            // if it was inactive, register it
            registerSubscription(context, sub);
        }
View Full Code Here

TOP

Related Classes of org.apache.activemq.broker.region.Subscription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.