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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterMessageProcessed
(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.void
Configure this component.void
connectComplete
(boolean reconnect, String brokerUrl) void
connectionLost
(Throwable throwable) void
deliveryComplete
(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> void
messageArrived
(String topic, org.eclipse.paho.client.mqttv3.MqttMessage message) void
setExceptionListener
(IbisExceptionListener ibisExceptionListener) Set a (single) listener that will be notified of any exceptions.void
setHandler
(IMessageHandler<org.eclipse.paho.client.mqttv3.MqttMessage> messageHandler) Set the handler that will do the processing of the message.void
setReceiver
(Receiver<org.eclipse.paho.client.mqttv3.MqttMessage> receiver) void
start()
Prepares the listener for receiving messages.void
stop()
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
getLogPrefix, getPhysicalDestinationName, setCharset, setName, setQos, setResourceName, setTopic, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
Methods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoader
Methods inherited from interface org.frankframework.core.HasPhysicalDestination
getDomain
-
Constructor Details
-
MqttListener
public MqttListener()
-
-
Method Details
-
setReceiver
- Specified by:
setReceiver
in interfaceReceiverAware<org.eclipse.paho.client.mqttv3.MqttMessage>
-
getReceiver
- Specified by:
getReceiver
in interfaceReceiverAware<org.eclipse.paho.client.mqttv3.MqttMessage>
-
setHandler
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 interfaceIPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>
-
setExceptionListener
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 interfaceIPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>
-
configure
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 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:
configure
in interfaceIConfigurable
- Overrides:
configure
in classMqttFacade
- 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. -
stop
public void stop()Description copied from interface:IListener
Close all resources used for listening. Called once each time the listener is stopped. -
connectComplete
- Specified by:
connectComplete
in interfaceorg.eclipse.paho.client.mqttv3.MqttCallbackExtended
-
connectionLost
- Specified by:
connectionLost
in interfaceorg.eclipse.paho.client.mqttv3.MqttCallback
-
deliveryComplete
public void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token) - Specified by:
deliveryComplete
in interfaceorg.eclipse.paho.client.mqttv3.MqttCallback
-
messageArrived
- Specified by:
messageArrived
in 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:IPushingListener
Wrap a raw message in a MessageWrapper. PopulatePipeLineSession
with properties from the message.- Specified by:
wrapRawMessage
in interfaceIPushingListener<org.eclipse.paho.client.mqttv3.MqttMessage>
- Parameters:
message
- The raw message data, unwrappedsession
-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 fromIPullingListener.getRawMessage(Map)
orIPushingListener.wrapRawMessage(Object, PipeLineSession)
. May also extract other parameters from the message and put those into the context.- Specified by:
extractMessage
in interfaceIListener<org.eclipse.paho.client.mqttv3.MqttMessage>
- Parameters:
rawMessage
- TheRawMessageWrapper
from which to extract theMessage
.context
- Context to populate. Either aPipeLineSession
or aMap
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 interfaceIListener<org.eclipse.paho.client.mqttv3.MqttMessage>
-