Package net.solarnetwork.central.support
Class MqttJsonPublisher<T>
java.lang.Object
net.solarnetwork.service.support.BasicIdentifiable
net.solarnetwork.central.support.BaseMqttConnectionObserver
net.solarnetwork.central.support.MqttJsonPublisher<T>
- All Implemented Interfaces:
Function<T,,Future<?>> net.solarnetwork.common.mqtt.MqttConnectionObserver,net.solarnetwork.service.Identifiable
public class MqttJsonPublisher<T>
extends BaseMqttConnectionObserver
implements Function<T,Future<?>>
Basic service to publish objects to SolarFlux.
-
Field Summary
Fields inherited from class net.solarnetwork.central.support.BaseMqttConnectionObserver
DEFAULT_PUBLISH_QOS, DEFAULT_PUBLISH_TIMEOUT_SECONDS, DEFAULT_SUBSCRIBE_QOS, DEFAULT_SUBSCRIBE_TIMEOUT_SECONDS, DEFAULT_TRANSIENT_ERROR_TRIES, log, mqttConnectionFields inherited from interface net.solarnetwork.service.Identifiable
GROUP_UID_PROPERTY, UID_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionMqttJsonPublisher(String name, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Function<T, String> topicFn, boolean retained, net.solarnetwork.common.mqtt.MqttQos publishQos) Constructor. -
Method Summary
Methods inherited from class net.solarnetwork.central.support.BaseMqttConnectionObserver
getMqttStats, getPublishQos, getPublishTimeoutSeconds, getSubscribeQos, getSubscribeTimeoutSeconds, getTransientErrorTries, isConnected, isRetained, onMqttServerConnectionEstablished, onMqttServerConnectionLost, setMqttStats, setPublishQos, setPublishQosLevel, setPublishTimeoutSeconds, setRetained, setSubscribeQos, setSubscribeQosLevel, setSubscribeTimeoutSeconds, setTransientErrorTries, toStringMethods inherited from class net.solarnetwork.service.support.BasicIdentifiable
basicIdentifiableMetadataSettings, basicIdentifiableSettings, basicIdentifiableSettings, basicIdentifiableSettings, doubleMetadataValue, getDisplayName, getGroupUid, getGroupUID, getMessageSource, getMetadata, getMetadataCount, getUid, getUID, integerMetadataValue, metadataValue, numberMetadataValue, saveMetadataValue, saveMetadataValue, setDisplayName, setGroupUid, setGroupUID, setMessageSource, setMetadata, setMetadataCount, setUid, setUID, smartMetadataValue
-
Constructor Details
-
MqttJsonPublisher
public MqttJsonPublisher(String name, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Function<T, String> topicFn, boolean retained, net.solarnetwork.common.mqtt.MqttQos publishQos) Constructor.- Parameters:
name- the display name to useobjectMapper- the mapper for JSONtopicFn- the function to generate the MQTT topic for a given objectretained- true to publish each message as retainedpublishQos- the publish QoS
-
-
Method Details
-
apply
-
publish
Publish an item to a given topic.- Parameters:
item- the itemtopic- the topic- Returns:
- the publish future
-
publish
protected Future<?> publish(T item, String topic, boolean retained, net.solarnetwork.common.mqtt.MqttQos qos) Publish an item to a given topic.- Parameters:
item- the itemtopic- the topicretained- true if the message should have theretainedflag setqos- the publish QoS to use- Returns:
- the publish future
- Since:
- 1.1
-