Package org.apache.activemq.broker.region

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


        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


        ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer) session.createConsumer(brokerZeroQueue);
        assertEquals("broker config prefetch in effect", 0, consumer.info.getCurrentPrefetchSize());

        // verify sub view broker
        Subscription sub =
                broker.getRegionBroker().getDestinationMap().get(ActiveMQDestination.transform(brokerZeroQueue)).getConsumers().get(0);
        assertEquals("broker sub prefetch is correct", 0, sub.getConsumerInfo().getCurrentPrefetchSize());

        // manipulate Prefetch (like failover and stomp)
        ConsumerControl consumerControl = new ConsumerControl();
        consumerControl.setConsumerId(consumer.info.getConsumerId());
        consumerControl.setDestination(ActiveMQDestination.transform(brokerZeroQueue));
        consumerControl.setPrefetch(1000); // default for a q

        Object reply = ((ActiveMQConnection) connection).getTransport().request(consumerControl);
        assertTrue("good request", !(reply instanceof ExceptionResponse));
        assertEquals("broker config prefetch in effect", 0, consumer.info.getCurrentPrefetchSize());
        assertEquals("broker sub prefetch is correct", 0, sub.getConsumerInfo().getCurrentPrefetchSize());
    }
View Full Code Here

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

        fireAdvisory(context, topic, info);
        connections.put(info.getConnectionId(), info);
    }

    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
        Subscription answer = next.addConsumer(context, info);
       
        // Don't advise advisory topics.
        if (!AdvisorySupport.isAdvisoryTopic(info.getDestination())) {
            ActiveMQTopic topic = AdvisorySupport.getConsumerAdvisoryTopic(info.getDestination());
            consumers.put(info.getConsumerId(), info);
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

        }
    }

    @Override
    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
        Subscription answer = next.addConsumer(context, info);
        Broker brokers[] = getListeners();
        for (int i = 0; i < brokers.length; i++) {
            brokers[i].addConsumer(context, info);
        }
        return answer;
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;
                                LOG.debug("ignoring lower priority: {} [{}, {}] in favour of: {} [{}, {}]",
                                        new Object[]{ candidate,
                                                candidate.getConsumerInfo().getNetworkConsumerIds(),
                                                candidate.getConsumerInfo().getNetworkConsumerIds(),
                                                sub,
                                                sub.getConsumerInfo().getNetworkConsumerIds(),
                                                sub.getConsumerInfo().getNetworkConsumerIds() });
                            }
                        }
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 answer = super.addConsumer(context, info);
        generateFile();
        return answer;
    }
View Full Code Here

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

    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

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.