Class AbstractMqttMessageHandler<T extends com.hivemq.client.mqtt.MqttClient>

Type Parameters:
T - MQTT Client type
All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>, Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, ApplicationEventPublisherAware, Ordered, ComponentSourceAware, ExpressionCapable, Orderable, IntegrationPattern, NamedComponent, IntegrationManagement, TrackableComponent, MessageHandler, reactor.core.CoreSubscriber<Message<?>>
Direct Known Subclasses:
Mqtt3MessageHandler, Mqtt5MessageHandler

public abstract class AbstractMqttMessageHandler<T extends com.hivemq.client.mqtt.MqttClient> extends AbstractMessageHandler implements ApplicationEventPublisherAware
Abstract class for MQTT Outbound Adapters.
Since:
7.2
Author:
Jiandong Ma, Artem Bilan
  • Constructor Details

    • AbstractMqttMessageHandler

      protected AbstractMqttMessageHandler(ClientManager<T> mqttClientManager)
  • Method Details

    • setApplicationEventPublisher

      public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
      Specified by:
      setApplicationEventPublisher in interface ApplicationEventPublisherAware
    • setMessageConverter

      public void setMessageConverter(MessageConverter messageConverter)
      Set the message converter to use.
      Parameters:
      messageConverter - the messageConverter.
    • setAsync

      public void setAsync(boolean async)
      Set to true if you don't want to block when sending messages. Default false. When true, message sent/delivered events will be published for reception by a suitably configured 'ApplicationListener' or an event inbound-channel-adapter.
      Parameters:
      async - true for async.
    • setDefaultTopic

      public void setDefaultTopic(String defaultTopic)
      Set the topic to which the message will be published if the topicExpression evaluates to `null`.
      Parameters:
      defaultTopic - the default topic.
    • setTopicExpression

      public void setTopicExpression(Expression topicExpression)
      Set the topic expression; default headers['mqtt_topic'].
      Parameters:
      topicExpression - the expression.
    • setTopicExpressionString

      public void setTopicExpressionString(String topicExpression)
      Set the topic expression; default headers['mqtt_topic'].
      Parameters:
      topicExpression - the expression.
    • setDefaultQos

      public void setDefaultQos(com.hivemq.client.mqtt.datatypes.MqttQos defaultQos)
      Set the qos for messages if the qosExpression evaluates to null.
      Parameters:
      defaultQos - the default qos.
    • setQosExpression

      public void setQosExpression(Expression qosExpression)
      Set the qos expression; default headers['mqtt_qos'].
      Parameters:
      qosExpression - the expression.
    • setQosExpressionString

      public void setQosExpressionString(String qosExpression)
      Set the qos expression; default headers['mqtt_qos'].
      Parameters:
      qosExpression - the expression.
    • setDefaultRetained

      public void setDefaultRetained(boolean defaultRetained)
      Set the retained boolean for messages if the retainedExpression evaluates to null.
      Parameters:
      defaultRetained - the defaultRetained.
    • setRetainedExpression

      public void setRetainedExpression(Expression retainedExpression)
      Set the retained expression; default headers['mqtt_retained'].
      Parameters:
      retainedExpression - the expression.
    • setRetainedExpressionString

      public void setRetainedExpressionString(String retainedExpression)
      Set the retained expression; default headers['mqtt_retained'].
      Parameters:
      retainedExpression - the expression.
    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class IntegrationObjectSupport
    • getEvaluationContext

      protected StandardEvaluationContext getEvaluationContext()
    • getClient

      protected T getClient()
    • isAsync

      protected boolean isAsync()
    • handleMessageInternal

      protected void handleMessageInternal(Message<?> message)
      Specified by:
      handleMessageInternal in class AbstractMessageHandler
    • isMqttMessage

      protected abstract boolean isMqttMessage(Object payload)
    • buildMqttMessage

      protected abstract Object buildMqttMessage(String topic, byte[] body, com.hivemq.client.mqtt.datatypes.MqttQos qos, boolean retained, Message<?> message)
    • publishMqttMessage

      protected abstract void publishMqttMessage(Object messageForPublish, Message<?> message)
    • messageSentEvent

      protected void messageSentEvent(Message<?> message, Object mqttPublish)
    • sendDeliveryCompleteEvent

      protected void sendDeliveryCompleteEvent(Object mqttPublishResult)
    • sendFailedDeliveryEvent

      protected void sendFailedDeliveryEvent(Object mqttPublishResult, Throwable ex)
    • getComponentType

      public String getComponentType()
      Specified by:
      getComponentType in interface NamedComponent
      Overrides:
      getComponentType in class MessageHandlerSupport