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
-
Field Summary
Fields inherited from class org.frankframework.extensions.mqtt.MqttFacade
client, mqttClientFactoryFactory, resourceName -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<org.eclipse.paho.client.mqttv3.MqttMessage> rawMessage, PipeLineSession pipeLineSession) Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.voidConfigure this component.voidconnectComplete(boolean reconnect, String brokerUrl) voidconnectionLost(Throwable throwable) voiddeliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token) extractMessage(RawMessageWrapper<org.eclipse.paho.client.mqttv3.MqttMessage> rawMessage, Map<String, Object> context) Extracts data from message obtained fromIPullingListener.getRawMessage(Map)orIPushingListener.wrapRawMessage(Object, PipeLineSession).Receiver<org.eclipse.paho.client.mqttv3.MqttMessage> voidmessageArrived(String topic, org.eclipse.paho.client.mqttv3.MqttMessage message) voidsetExceptionListener(IbisExceptionListener ibisExceptionListener) Set a (single) listener that will be notified of any exceptions.voidsetHandler(IMessageHandler<org.eclipse.paho.client.mqttv3.MqttMessage> messageHandler) Set the handler that will do the processing of the message.voidsetReceiver(Receiver<org.eclipse.paho.client.mqttv3.MqttMessage> receiver) voidstart()Prepares the listener for receiving messages.voidstop()Close all resources used for listening.RawMessageWrapper<org.eclipse.paho.client.mqttv3.MqttMessage> wrapRawMessage(org.eclipse.paho.client.mqttv3.MqttMessage message, PipeLineSession session) Wrap a raw message in a MessageWrapper.Methods inherited from class org.frankframework.extensions.mqtt.MqttFacade
getClientFactory, getLogPrefix, getPhysicalDestinationName, setCharset, setName, setQos, setResourceName, setTopic, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoader
-
Constructor Details
-
MqttListener
public MqttListener()
-
-
Method Details
-
setReceiver
- Specified by:
setReceiverin interfaceReceiverAware<org.eclipse.paho.client.mqttv3.MqttMessage>
-
getReceiver
- Specified by:
getReceiverin interfaceReceiverAware<org.eclipse.paho.client.mqttv3.MqttMessage>
-
setHandler
Description copied from interface:IPushingListenerSet the handler that will do the processing of the message. Each of the received messages must be pushed through handler.processMessage()- Specified by:
setHandlerin interfaceIPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>
-
setExceptionListener
Description copied from interface:IPushingListenerSet 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:
setExceptionListenerin interfaceIPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. 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 theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Overrides:
configurein classMqttFacade- Throws:
ConfigurationException- in case it was not able to configure the component.
-
start
public void start()Description copied from interface:IListenerPrepares the listener for receiving messages.start()is called once each time the listener is started. -
stop
public void stop()Description copied from interface:IListenerClose all resources used for listening. Called once each time the listener is stopped. -
connectComplete
- Specified by:
connectCompletein interfaceorg.eclipse.paho.client.mqttv3.MqttCallbackExtended
-
connectionLost
- Specified by:
connectionLostin interfaceorg.eclipse.paho.client.mqttv3.MqttCallback
-
deliveryComplete
public void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token) - Specified by:
deliveryCompletein interfaceorg.eclipse.paho.client.mqttv3.MqttCallback
-
messageArrived
- Specified by:
messageArrivedin interfaceorg.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:IPushingListenerWrap a raw message in a MessageWrapper. PopulatePipeLineSessionwith properties from the message.- Specified by:
wrapRawMessagein interfaceIPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>- Parameters:
message- The raw message data, unwrappedsession-PipeLineSessionto 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:IListenerExtracts data from message obtained fromIPullingListener.getRawMessage(Map)orIPushingListener.wrapRawMessage(Object, PipeLineSession). May also extract other parameters from the message and put those into the context.- Specified by:
extractMessagein interfaceIListener<org.eclipse.paho.client.mqttv3.MqttMessage>- Parameters:
rawMessage- TheRawMessageWrapperfrom which to extract theMessage.context- Context to populate. Either aPipeLineSessionor aMapthreadContext depending on caller.- Returns:
- input
Messagefor adapter.
-
afterMessageProcessed
public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<org.eclipse.paho.client.mqttv3.MqttMessage> rawMessage, PipeLineSession pipeLineSession) Description copied from interface:IListenerCalled to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.- Specified by:
afterMessageProcessedin interfaceIListener<org.eclipse.paho.client.mqttv3.MqttMessage>
-