Class AbstractMQTTSubscriptionStrategy

    • Constructor Detail

      • AbstractMQTTSubscriptionStrategy

        public AbstractMQTTSubscriptionStrategy()
    • Method Detail

      • onSubscribe

        public byte onSubscribe​(org.fusesource.mqtt.client.Topic topic)
                         throws MQTTProtocolException
        Description copied from interface: MQTTSubscriptionStrategy
        Called for each Topic that a client requests to subscribe to. The strategy needs check each Topic for duplicate subscription requests and change of QoS state.
        Specified by:
        onSubscribe in interface MQTTSubscriptionStrategy
        Parameters:
        topic - the MQTT Topic instance being subscribed to.
        Returns:
        the assigned QoS value given to the new subscription.
        Throws:
        MQTTProtocolException - if an error occurs while processing the subscribe actions.
      • onReSubscribe

        public void onReSubscribe​(MQTTSubscription mqttSubscription)
                           throws MQTTProtocolException
        Description copied from interface: MQTTSubscriptionStrategy
        Called when a client sends a duplicate subscribe request which should force any retained messages on that topic to be replayed again as though the client had just subscribed for the first time. The method should not unsubscribe the client as it might miss messages sent while the subscription is being recreated.
        Specified by:
        onReSubscribe in interface MQTTSubscriptionStrategy
        Parameters:
        mqttSubscription - the MQTTSubscription that contains the subscription state.
        Throws:
        MQTTProtocolException
      • onSend

        public org.apache.activemq.command.ActiveMQDestination onSend​(String topicName)
        Description copied from interface: MQTTSubscriptionStrategy
        Intercepts PUBLISH operations from the client and allows the strategy to map the target destination so that the send operation will land in the destinations that this strategy has mapped the incoming subscribe requests to.
        Specified by:
        onSend in interface MQTTSubscriptionStrategy
        Parameters:
        topicName - the targeted Topic that the client sent the message to.
        Returns:
        an ActiveMQ Topic instance that lands the send in the correct destinations.
      • onSend

        public String onSend​(org.apache.activemq.command.ActiveMQDestination destination)
        Description copied from interface: MQTTSubscriptionStrategy
        Intercepts send operations from the broker and allows the strategy to map the target topic name so that the client sees a valid Topic name.
        Specified by:
        onSend in interface MQTTSubscriptionStrategy
        Parameters:
        destination - the destination that the message was dispatched from
        Returns:
        an Topic name that is valid for the receiving client.
      • isControlTopic

        public boolean isControlTopic​(org.apache.activemq.command.ActiveMQDestination destination)
        Description copied from interface: MQTTSubscriptionStrategy
        Allows the protocol handler to interrogate an destination name to determine if it is equivalent to the MQTT control topic (starts with $). Since the mapped destinations that the strategy might alter the naming scheme the strategy must provide a way to reverse map and determine if the destination was originally an MQTT control topic.
        Specified by:
        isControlTopic in interface MQTTSubscriptionStrategy
        Parameters:
        destination - the destination to query.
        Returns:
        true if the destination is an MQTT control topic.
      • getNextConsumerId

        protected org.apache.activemq.command.ConsumerId getNextConsumerId()
      • deleteDurableSubs

        protected void deleteDurableSubs​(List<org.apache.activemq.command.SubscriptionInfo> subs)
      • restoreDurableSubs

        protected void restoreDurableSubs​(List<org.apache.activemq.command.SubscriptionInfo> subs)