Package org.apache.activemq.transport.mqtt

Examples of org.apache.activemq.transport.mqtt.MQTTProtocolException


                onUnSubscribe(destinationName);
            } else {
                try {
                    onReSubscribe(mqttSubscription);
                } catch (IOException e) {
                    throw new MQTTProtocolException("Failed to find subscription strategy", true, e);
                }
                return (byte) requestedQoS.ordinal();
            }
        }

        try {
            return onSubscribe(destinationName, requestedQoS);
        } catch (IOException e) {
            throw new MQTTProtocolException("Failed while intercepting subscribe", true, e);
        }
    }
View Full Code Here


        // get TopicRegion
        RegionBroker regionBroker;
        try {
            regionBroker = (RegionBroker) brokerService.getBroker().getAdaptor(RegionBroker.class);
        } catch (Exception e) {
            throw new MQTTProtocolException("Error subscribing to " + topicName + ": " + e.getMessage(), false, e);
        }
        final TopicRegion topicRegion = (TopicRegion) regionBroker.getTopicRegion();

        final ConsumerInfo consumerInfo = mqttSubscription.getConsumerInfo();
        final ConsumerId consumerId = consumerInfo.getConsumerId();

        // use actual client id used to create connection to lookup connection
        // context
        final String connectionInfoClientId = protocol.getClientId();
        final ConnectionContext connectionContext = regionBroker.getConnectionContext(connectionInfoClientId);

        // get all matching Topics
        final Set<org.apache.activemq.broker.region.Destination> matchingDestinations =
            topicRegion.getDestinations(mqttSubscription.getDestination());
        for (org.apache.activemq.broker.region.Destination dest : matchingDestinations) {

            // recover retroactive messages for matching subscription
            for (Subscription subscription : dest.getConsumers()) {
                if (subscription.getConsumerInfo().getConsumerId().equals(consumerId)) {
                    try {
                        if (dest instanceof org.apache.activemq.broker.region.Topic) {
                            ((org.apache.activemq.broker.region.Topic) dest).recoverRetroactiveMessages(connectionContext, subscription);
                        } else if (dest instanceof VirtualTopicInterceptor) {
                            ((VirtualTopicInterceptor) dest).getTopic().recoverRetroactiveMessages(connectionContext, subscription);
                        }
                        if (subscription instanceof PrefetchSubscription) {
                            // request dispatch for prefetch subs
                            PrefetchSubscription prefetchSubscription = (PrefetchSubscription) subscription;
                            prefetchSubscription.dispatchPending();
                        }
                    } catch (Exception e) {
                        throw new MQTTProtocolException("Error recovering retained messages for " + dest.getName() + ": " + e.getMessage(), false, e);
                    }
                    break;
                }
            }
        }
View Full Code Here

    public void onConnect(CONNECT connect) throws MQTTProtocolException {
        List<SubscriptionInfo> subs;
        try {
            subs = PersistenceAdapterSupport.listSubscriptions(brokerService.getPersistenceAdapter(), protocol.getClientId());
        } catch (IOException e) {
            throw new MQTTProtocolException("Error loading store subscriptions", true, e);
        }
        if (connect.cleanSession()) {
            deleteDurableSubs(subs);
        } else {
            restoreDurableSubs(subs);
View Full Code Here

                    }
                    return false;
                }
            });
        } catch (IOException e) {
            throw new MQTTProtocolException("Error restoring durable subscriptions", true, e);
        }

        if (connect.cleanSession()) {
            deleteDurableQueues(queues);
        } else {
View Full Code Here

TOP

Related Classes of org.apache.activemq.transport.mqtt.MQTTProtocolException

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.