Class MqttListener

java.lang.Object
org.frankframework.extensions.mqtt.MqttFacade
org.frankframework.extensions.mqtt.MqttListener
All Implemented Interfaces:
org.eclipse.paho.client.mqttv3.MqttCallback, org.eclipse.paho.client.mqttv3.MqttCallbackExtended, FrankElement, HasApplicationContext, HasName, HasPhysicalDestination, IConfigurable, IListener<org.eclipse.paho.client.mqttv3.MqttMessage>, IPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>, IScopeProvider, NameAware, ReceiverAware<org.eclipse.paho.client.mqttv3.MqttMessage>, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

public class MqttListener extends MqttFacade implements ReceiverAware<org.eclipse.paho.client.mqttv3.MqttMessage>, IPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>, org.eclipse.paho.client.mqttv3.MqttCallbackExtended
MQTT listener which will connect to a broker and subscribe to a topic. Links to https://www.eclipse.org/paho/files/javadoc are opened in a new window/tab because the response from eclipse.org contains header X-Frame-Options:SAMEORIGIN which will make the browser refuse to open the link inside this frame.
Author:
Jaco de Groot, Niels Meijer
  • Constructor Details

    • MqttListener

      public MqttListener()
  • Method Details

    • setReceiver

      public void setReceiver(Receiver<org.eclipse.paho.client.mqttv3.MqttMessage> receiver)
      Specified by:
      setReceiver in interface ReceiverAware<org.eclipse.paho.client.mqttv3.MqttMessage>
    • getReceiver

      public Receiver<org.eclipse.paho.client.mqttv3.MqttMessage> getReceiver()
      Specified by:
      getReceiver in interface ReceiverAware<org.eclipse.paho.client.mqttv3.MqttMessage>
    • setHandler

      public void setHandler(IMessageHandler<org.eclipse.paho.client.mqttv3.MqttMessage> messageHandler)
      Description copied from interface: IPushingListener
      Set the handler that will do the processing of the message. Each of the received messages must be pushed through handler.processMessage()
      Specified by:
      setHandler in interface IPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>
    • setExceptionListener

      public void setExceptionListener(IbisExceptionListener ibisExceptionListener)
      Description copied from interface: IPushingListener
      Set a (single) listener that will be notified of any exceptions. The listener should use this listener to notify the receiver of any exception that occurs outside the processing of a message.
      Specified by:
      setExceptionListener in interface IPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>
    • configure

      public void configure() throws ConfigurationException
      Description copied from interface: IConfigurable
      Configure this component.

      configure() is called once at startup of the framework in the configure method of the owner of this IConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in the configure(), to improve performance.

      In the case of a container, this will propagate the configure signal to all components that apply.

      Specified by:
      configure in interface IConfigurable
      Overrides:
      configure in class MqttFacade
      Throws:
      ConfigurationException - in case it was not able to configure the component.
    • start

      public void start()
      Description copied from interface: IListener
      Prepares the listener for receiving messages. start() is called once each time the listener is started.
      Specified by:
      start in interface IListener<org.eclipse.paho.client.mqttv3.MqttMessage>
    • stop

      public void stop()
      Description copied from interface: IListener
      Close all resources used for listening. Called once each time the listener is stopped.
      Specified by:
      stop in interface IListener<org.eclipse.paho.client.mqttv3.MqttMessage>
    • connectComplete

      public void connectComplete(boolean reconnect, String brokerUrl)
      Specified by:
      connectComplete in interface org.eclipse.paho.client.mqttv3.MqttCallbackExtended
    • connectionLost

      public void connectionLost(Throwable throwable)
      Specified by:
      connectionLost in interface org.eclipse.paho.client.mqttv3.MqttCallback
    • deliveryComplete

      public void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token)
      Specified by:
      deliveryComplete in interface org.eclipse.paho.client.mqttv3.MqttCallback
    • messageArrived

      public void messageArrived(String topic, org.eclipse.paho.client.mqttv3.MqttMessage message)
      Specified by:
      messageArrived in interface org.eclipse.paho.client.mqttv3.MqttCallback
    • wrapRawMessage

      public RawMessageWrapper<org.eclipse.paho.client.mqttv3.MqttMessage> wrapRawMessage(org.eclipse.paho.client.mqttv3.MqttMessage message, PipeLineSession session)
      Description copied from interface: IPushingListener
      Wrap a raw message in a MessageWrapper. Populate PipeLineSession with properties from the message.
      Specified by:
      wrapRawMessage in interface IPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>
      Parameters:
      message - The raw message data, unwrapped
      session - PipeLineSession to populate with properties from the message.
      Returns:
      Wrapped raw message
    • extractMessage

      public Message extractMessage(@Nonnull RawMessageWrapper<org.eclipse.paho.client.mqttv3.MqttMessage> rawMessage, @Nonnull Map<String,Object> context)
      Description copied from interface: IListener
      Extracts data from message obtained from IPullingListener.getRawMessage(Map) or IPushingListener.wrapRawMessage(Object, PipeLineSession). May also extract other parameters from the message and put those into the context.
      Specified by:
      extractMessage in interface IListener<org.eclipse.paho.client.mqttv3.MqttMessage>
      Parameters:
      rawMessage - The RawMessageWrapper from which to extract the Message.
      context - Context to populate. Either a PipeLineSession or a Map threadContext depending on caller.
      Returns:
      input Message for adapter.
    • afterMessageProcessed

      public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<org.eclipse.paho.client.mqttv3.MqttMessage> rawMessage, PipeLineSession pipeLineSession)
      Description copied from interface: IListener
      Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.
      Specified by:
      afterMessageProcessed in interface IListener<org.eclipse.paho.client.mqttv3.MqttMessage>