Class AbstractSubscription

    • Constructor Detail

      • AbstractSubscription

        protected AbstractSubscription​(org.eclipse.hono.util.ResourceIdentifier topicResource,
                                       io.netty.handler.codec.mqtt.MqttQoS qos,
                                       org.eclipse.hono.auth.Device authenticatedDevice)
        Creates a new AbstractSubscription.
        Parameters:
        topicResource - The topic to subscribe for.
        qos - The quality-of-service level for the subscription.
        authenticatedDevice - The authenticated device or null.
        Throws:
        NullPointerException - if topicResource or qos is null.
        IllegalArgumentException - if the topic does not match the rules.
    • Method Detail

      • getTenant

        public final String getTenant()
        Description copied from interface: Subscription
        Gets the tenant from topic or authentication.
        Specified by:
        getTenant in interface Subscription
        Returns:
        The tenant (never null).
      • getDeviceId

        public final String getDeviceId()
        Description copied from interface: Subscription
        Gets the device id from topic or authentication.
        Specified by:
        getDeviceId in interface Subscription
        Returns:
        The device id (never null).
      • getEndpoint

        public final String getEndpoint()
        Description copied from interface: Subscription
        Gets the endpoint of the subscription.
        Specified by:
        getEndpoint in interface Subscription
        Returns:
        The endpoint.
      • getQos

        public final io.netty.handler.codec.mqtt.MqttQoS getQos()
        Description copied from interface: Subscription
        Gets the QoS of the subscription.
        Specified by:
        getQos in interface Subscription
        Returns:
        The QoS value.
      • getTopic

        public final String getTopic()
        Description copied from interface: Subscription
        Gets the subscription topic.
        Specified by:
        getTopic in interface Subscription
        Returns:
        The topic.
      • isAuthenticated

        public final boolean isAuthenticated()
        Description copied from interface: Subscription
        Gets the authentication status, which indicates the need to publish on tenant/device-id for unauthenticated devices.
        Specified by:
        isAuthenticated in interface Subscription
        Returns:
        true if created with an authenticated device.
      • isGatewaySubscriptionForSpecificDevice

        public final boolean isGatewaySubscriptionForSpecificDevice()
        Description copied from interface: Subscription
        Checks whether this subscription represents the case of a gateway subscribing for a specific device that it acts on behalf of.
        Specified by:
        isGatewaySubscriptionForSpecificDevice in interface Subscription
        Returns:
        true if a gateway is subscribing for a specific device.
      • containsTenantId

        public boolean containsTenantId()
        Description copied from interface: Subscription
        Checks if the topic contains a tenant identifier.
        Specified by:
        containsTenantId in interface Subscription
        Returns:
        true if the topic contains a tenant id.
      • containsDeviceId

        public boolean containsDeviceId()
        Description copied from interface: Subscription
        Checks if the topic contains a device identifier.
        Specified by:
        containsDeviceId in interface Subscription
        Returns:
        true if the topic contains a device id.
      • logSubscribeSuccess

        public final void logSubscribeSuccess​(io.opentracing.Span span)
        Description copied from interface: Subscription
        Logs a successful subscription attempt to the given span.
        Specified by:
        logSubscribeSuccess in interface Subscription
        Parameters:
        span - The span to log to.
      • logSubscribeFailure

        public final void logSubscribeFailure​(io.opentracing.Span span,
                                              Throwable error)
        Description copied from interface: Subscription
        Logs a failed subscription attempt to the given span.
        Specified by:
        logSubscribeFailure in interface Subscription
        Parameters:
        span - The span to log to.
        error - The error to log.
      • logUnsubscribe

        public final void logUnsubscribe​(io.opentracing.Span span)
        Description copied from interface: Subscription
        Logs the unsubscription to the given span.
        Specified by:
        logUnsubscribe in interface Subscription
        Parameters:
        span - The span to log to.