Package org.activemq.service

Examples of org.activemq.service.Subscription


        // unless via the deleteSubscription() method
       
//        subscriptionContainer.removeSubscription(info.getConsumerId());
//        subscription.clear();
       
        Subscription sub = (Subscription) activeSubscriptions.remove(info.getConsumerId());
        if (sub != null) {
            sub.setActive(false);
            dispatcher.removeActiveSubscription(client, sub);
        }
    }
View Full Code Here


     * @throws javax.jms.JMSException if the subscriber doesn't exist or is still active
     */
    public void deleteSubscription(String clientId, String subscriberName) throws JMSException {
       
        String consumerKey = ConsumerInfo.generateConsumerKey(clientId, subscriberName);       
        Subscription sub = (Subscription) durableSubscriptions.remove(consumerKey);
        if( sub!=null ) {
            //only delete if not active
            if (sub.isActive()) {
                throw new JMSException("The Consummer " + subscriberName + " is still active");
            }
            else {
                subscriptionContainer.removeSubscription(sub.getConsumerId());
                sub.clear();
               
                Set containers = destinationMap.get(sub.getDestination());
                for (Iterator iter = containers.iterator();iter.hasNext();) {
                    TopicMessageContainer container = (TopicMessageContainer) iter.next();
                    if (container instanceof DurableTopicMessageContainer) {
                        ((DurableTopicMessageContainer) container).deleteSubscription(sub.getPersistentKey());
                    }
                }
               
            }
        } else {
View Full Code Here

     */
    private void doSendMessage(BrokerClient client, ActiveMQMessage message, MessageContainer container) throws JMSException {
        Set matchingSubscriptions = subscriptionContainer.getSubscriptions(message.getJMSActiveMQDestination());
        if (!matchingSubscriptions.isEmpty()) {
            for (Iterator i = matchingSubscriptions.iterator();i.hasNext();) {
                Subscription sub = (Subscription) i.next();
                if (sub.isTarget(message)) {
                    sub.addMessage(container, message);
                }
            }
            updateSendStats(client, message);
        }       
    }
View Full Code Here

     * @return
     */
    public Map getLocalDestinations() {
        Map localDestinations = new HashMap();
        for (Iterator iter = subscriptionContainer.subscriptionIterator(); iter.hasNext();) {
            Subscription sub = (Subscription) iter.next();
            if (sub.isLocalSubscription()) {
                final ActiveMQDestination dest = sub.getDestination();
                localDestinations.put(dest.getPhysicalName(), dest);
            }
        }
        return Collections.unmodifiableMap(localDestinations);
    }
View Full Code Here

     */
    public void acknowledgeMessage(BrokerClient client, final MessageAck ack) throws JMSException {
        if ( !ack.getDestination().isTopic() || !ack.isPersistent())
            return;
           
        Subscription sub = (Subscription) activeSubscriptions.get(ack.getConsumerId());
        if (sub == null) {
            return;
        }
       
        sub.messageConsumed(ack);
    }
View Full Code Here

        return new ActiveMQTopic(destinationName);
    }

    public boolean isConsumerActiveOnDestination(ActiveMQDestination dest) {
        for (Iterator iter = activeSubscriptions.values().iterator();iter.hasNext();) {
            Subscription subscription = (Subscription) iter.next();
            if( subscription.getDestination().equals(dest) ) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

   
    protected void doAddMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException {
        boolean shouldRecover = false;
        if (info.getConsumerName() != null && info.getClientId() != null) {
            for (Iterator iter = activeSubscriptions.values().iterator();iter.hasNext();) {
                Subscription subscription = (Subscription) iter.next();
                if (subscription.isSameDurableSubscription(info)) {
                    throw new DuplicateDurableSubscriptionException(info);
                }
            }
        }       
        Subscription subscription = (Subscription) durableSubscriptions.get(info.getConsumerKey())
        //subscriptionContainer.getSubscription(info.getConsumerId());
        if (subscription != null) {
            //check the subscription hasn't changed
            if (!equal(subscription.getDestination(), info.getDestination())
                    || !equal(subscription.getSelector(), info.getSelector())) {
                subscriptionContainer.removeSubscription(info.getConsumerId());
                subscription.clear();
                subscription = subscriptionContainer.makeSubscription(dispatcher, client, info, createFilter(info));
                durableSubscriptions.put(info.getConsumerKey(), subscription);
            }
        }
        else {
            subscription = subscriptionContainer.makeSubscription(dispatcher, client,info, createFilter(info));
            shouldRecover = true;
            durableSubscriptions.put(info.getConsumerKey(), subscription);
        }
        subscription.setActiveConsumer(client,info);
        activeSubscriptions.put(info.getConsumerId(), subscription);
        dispatcher.addActiveSubscription(client, subscription);
       
        // load the container
        getContainer(subscription.getDestination().getPhysicalName());
       
        Set containers = destinationMap.get(subscription.getDestination());
        for (Iterator iter = containers.iterator();iter.hasNext();) {
            TopicMessageContainer container = (TopicMessageContainer) iter.next();
            if (container instanceof DurableTopicMessageContainer) {
                ((DurableTopicMessageContainer) container).storeSubscription(info, subscription);
            }
        }
        if (shouldRecover) {
            recoverSubscriptions(subscription);
        }
        // lets not make the subscription active until later
        // as we can't start dispatching until we've sent back the receipt
        // TODO we might wish to register a post-receipt action here
        // to perform the wakeup
        subscription.setActive(true);
        //dispatcher.wakeup(subscription);
    }
View Full Code Here

        // unless via the deleteSubscription() method
       
//        subscriptionContainer.removeSubscription(info.getConsumerId());
//        subscription.clear();
       
        Subscription sub = (Subscription) activeSubscriptions.remove(info.getConsumerId());
        if (sub != null) {
            sub.setActive(false);
            dispatcher.removeActiveSubscription(client, sub);
        }
    }
View Full Code Here

     * @throws javax.jms.JMSException if the subscriber doesn't exist or is still active
     */
    public void deleteSubscription(String clientId, String subscriberName) throws JMSException {
       
        String consumerKey = ConsumerInfo.generateConsumerKey(clientId, subscriberName);       
        Subscription sub = (Subscription) durableSubscriptions.remove(consumerKey);
        if( sub!=null ) {
            //only delete if not active
            if (sub.isActive()) {
                throw new JMSException("The Consummer " + subscriberName + " is still active");
            }
            else {
                subscriptionContainer.removeSubscription(sub.getConsumerId());
                sub.clear();
               
                Set containers = destinationMap.get(sub.getDestination());
                for (Iterator iter = containers.iterator();iter.hasNext();) {
                    TopicMessageContainer container = (TopicMessageContainer) iter.next();
                    if (container instanceof DurableTopicMessageContainer) {
                        ((DurableTopicMessageContainer) container).deleteSubscription(sub.getPersistentKey());
                    }
                }
               
            }
        } else {
View Full Code Here

     */
    private void doSendMessage(BrokerClient client, ActiveMQMessage message, MessageContainer container) throws JMSException {
        Set matchingSubscriptions = subscriptionContainer.getSubscriptions(message.getJMSActiveMQDestination());
        if (!matchingSubscriptions.isEmpty()) {
            for (Iterator i = matchingSubscriptions.iterator();i.hasNext();) {
                Subscription sub = (Subscription) i.next();
                if (sub.isTarget(message)) {
                    sub.addMessage(container, message);
                }
            }
            updateSendStats(client, message);
        }       
    }
View Full Code Here

TOP

Related Classes of org.activemq.service.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.