Class ProtocolAdapterProperties


  • public class ProtocolAdapterProperties
    extends ServiceConfigProperties
    Common configuration properties for protocol adapters of Hono.
    • Field Detail

      • DEFAULT_TENANT_IDLE_TIMEOUT

        public static final Duration DEFAULT_TENANT_IDLE_TIMEOUT
        The default duration after which a tenant times out when no message has been sent for it. The default value disables automatic tenant timeout.
    • Constructor Detail

      • ProtocolAdapterProperties

        public ProtocolAdapterProperties()
    • Method Detail

      • isAuthenticationRequired

        public final boolean isAuthenticationRequired()
        Checks whether the protocol adapter always authenticates devices using their provided credentials as defined in the Credentials API.

        If this property is false then devices are always allowed to publish data without providing credentials. This should only be set to false in test setups.

        The default value of this property is true.

        Returns:
        true if the protocol adapter demands the authentication of devices to allow the publishing of data.
      • setAuthenticationRequired

        public final void setAuthenticationRequired​(boolean authenticationRequired)
        Sets whether the protocol adapter always authenticates devices using their provided credentials as defined in the Credentials API.

        If this property is set to false then devices are always allowed to publish data without providing credentials. This should only be set to false in test setups.

        The default value of this property is true.

        Parameters:
        authenticationRequired - true if the server should wait for downstream connections to be established during startup.
      • setJmsVendorPropsEnabled

        public final void setJmsVendorPropsEnabled​(boolean flag)
        Sets if the adapter should include Vendor Properties as defined by Advanced Message Queuing Protocol (AMQP) JMS Mapping Version 1.0, Chapter 4 in downstream messages.

        Setting this property to true can be helpful if downstream consumers receive messages from Hono using a JMS provider which doesn't support the vendor properties but provides access to all application properties of received messages.

        If set to the adapter will add the following vendor properties to a message's application properties:

        • JMS_AMQP_CONTENT_TYPE - with the value of the standard AMQP 1.0 content-type property (if set)
        • JMS_AMQP_CONTENT_ENCODING - with the value of the standard AMQP 1.0 content-encoding property (if set)

        The default value of this property is false.

        Parameters:
        flag - true if the properties should be included.
      • isDefaultsEnabled

        public final boolean isDefaultsEnabled()
        Checks if the adapter should use default values registered for a device to augment messages published by the device.

        Default values that can be registered for devices include:

        • content-type - the default content type to set on a downstream message if the device did not specify a content type when it published the message. This is particularly useful for defining a content type for devices connected via MQTT which does not provide a standard way of setting a content type.
        Returns:
        true if the adapter should use default values.
      • setDefaultsEnabled

        public final void setDefaultsEnabled​(boolean flag)
        Sets if the adapter should use default values registered for a device to augment messages published by the device.

        Default values that can be registered for devices include:

        • content-type - the default content type to set on a downstream message if the device did not specify a content type when it published the message. This is particularly useful for defining a content type for devices connected via MQTT which does not provide a standard way of setting a content type.
        Parameters:
        flag - true if the adapter should use default values.
      • getEventLoopBlockedCheckTimeout

        public final long getEventLoopBlockedCheckTimeout()
        Gets the timeout value used by protocol adapter liveness check, which determines if protocol adapter vert.x event loop is blocked.

        Default value of the timeout is 5000 milliseconds.

        Returns:
        The timeout value in milliseconds.
      • setEventLoopBlockedCheckTimeout

        public final void setEventLoopBlockedCheckTimeout​(long eventLoopBlockedCheckTimeout)
        Sets the timeout value used by protocol adapter liveness check, which determines if protocol adapter vert.x event loop is blocked.

        Parameters:
        eventLoopBlockedCheckTimeout - Liveness check timeout value in milliseconds.
      • getMaxConnections

        public final int getMaxConnections()
        Gets the maximum number of concurrent connections that the protocol adapter accepts.

        The default value of this property is 0 which lets the protocol adapter determine an appropriate value based on e.g. available memory and CPU resources.

        Returns:
        The number of connections.
      • setMaxConnections

        public final void setMaxConnections​(int maxConnections)
        Sets the maximum number of concurrent connections that the protocol adapter should accept.

        Setting this property to 0 (the default value) will let the protocol adapter determine an appropriate value based on e.g. available memory and CPU resources.

        Parameters:
        maxConnections - The number of connections.
        Throws:
        IllegalArgumentException - if the number is < 0.
      • isConnectionLimitConfigured

        public final boolean isConnectionLimitConfigured()
        Checks if a connection limit has been configured.
        Returns:
        true if the maximum number of connections is > 0.
      • getTenantIdleTimeout

        public Duration getTenantIdleTimeout()
        Gets the duration after which a tenant times out when no messages had been sent for it.

        The default value of this property is DEFAULT_TENANT_IDLE_TIMEOUT, which disables automatic tenant timeout.

        Returns:
        The duration to wait for idle tenants.
      • setTenantIdleTimeout

        public void setTenantIdleTimeout​(Duration tenantIdleTimeout)
        Sets the duration after which a tenant times out when no messages had been sent for it.

        The default value of this property is DEFAULT_TENANT_IDLE_TIMEOUT, which disables automatic tenant timeout.

        Parameters:
        tenantIdleTimeout - The duration to wait for idle tenants.
        Throws:
        NullPointerException - if parameter is null.