Package org.chenile.mqtt.init
Class MqttInitializer
java.lang.Object
org.chenile.mqtt.init.MqttInitializer
Detects the
When a service is subscribed, all operations under the service will be subscribed automatically.
ChenileMqtt
annotated classes in the Application Context and
populates the mqttConfig for later use by MqttEntryPoint
Topic and Qos can be configured at the service level. (not at the operation level)When a service is subscribed, all operations under the service will be subscribed automatically.
-
Field Summary
Modifier and TypeFieldDescription(package private) ApplicationContext
private final String
private final String
(package private) ChenileConfiguration
(package private) org.slf4j.Logger
(package private) boolean
(package private) org.eclipse.paho.mqttv5.client.MqttAsyncClient
-
Constructor Summary
ConstructorDescriptionMqttInitializer
(boolean enabled, String basePublishTopic, String baseSubscribeTopic) -
Method Summary
Modifier and TypeMethodDescriptionvoid
init()
private void
putAnnotationBackIntoServiceDefinition
(String publishTopic, String subscribeTopic, int qos, String serviceId) Put the details of the data structure back into the service definition.
-
Field Details
-
logger
org.slf4j.Logger logger -
chenileConfiguration
-
mqttV5Client
-
applicationContext
-
mqttConfig
-
mqttEnabled
boolean mqttEnabled -
basePublishTopicName
-
baseSubscribeTopicName
-
-
Constructor Details
-
MqttInitializer
-
-
Method Details
-
init
@EventListener(org.springframework.boot.context.event.ApplicationReadyEvent.class) @Order(900) public void init() throws Exception- Throws:
Exception
-
putAnnotationBackIntoServiceDefinition
private void putAnnotationBackIntoServiceDefinition(String publishTopic, String subscribeTopic, int qos, String serviceId) Put the details of the data structure back into the service definition.
This is needed since the init method takes default values that are configured in the annotation and mutates them.- Parameters:
publishTopic
- - the topic to publish when you want to invoke the service remotelysubscribeTopic
- - the topic to subscribe for the serviceqos
- - the qos level to subscribe toserviceId
- - the service Id of the service that gets mapped to the topic and qos
-