Package org.apache.activemq.broker.region

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


        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.put(info.getConsumerId(), info);
View Full Code Here


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

    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.put(info.getConsumerId(), info);
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

    private void verifyPrefetch(final int val, final Destination dest) throws Exception {
        assertTrue("success in time", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                try {
                    Subscription sub =
                            brokerService.getRegionBroker().getDestinationMap().get(ActiveMQDestination.transform(dest)).getConsumers().get(0);
                    LOG.info("sub prefetch: " + sub.getConsumerInfo().getPrefetchSize());
                    return val == sub.getConsumerInfo().getPrefetchSize();
                } catch (Exception ignored) {
                }
                return false;
            }
        }));
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 = safeGetBroker().addConsumer(context, info);
        safeGetBroker().removeConsumer(context, info);
        if (subscription != null) {
            return subscription.getObjectName();
        }
        return null;
    }
View Full Code Here

    private void verifyPrefetch(final int val, final Destination dest) throws Exception {
        assertTrue("success in time", Wait.waitFor(new Wait.Condition() {
            @Override
            public boolean isSatisified() throws Exception {
                try {
                    Subscription sub =
                            brokerService.getRegionBroker().getDestinationMap().get(ActiveMQDestination.transform(dest)).getConsumers().get(0);
                    LOG.info("sub prefetch: " + sub.getConsumerInfo().getPrefetchSize());
                    return val == sub.getConsumerInfo().getPrefetchSize();
                } catch (Exception ignored) {
                }
                return false;
            }
        }));
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.put(info.getConsumerId(), info);
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

    public ObjectName getSubscriberObjectName(Subscription key) {
        return subscriptionMap.get(key);
    }

    public Subscription getSubscriber(ObjectName key) {
        Subscription sub = null;
        for (Entry<Subscription, ObjectName> entry: subscriptionMap.entrySet()) {
            if (entry.getValue().equals(key)) {
                sub = entry.getKey();
                break;
            }
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.