Class MqttConfiguration

java.lang.Object
org.chenile.configuration.mqtt.MqttConfiguration

@Configuration public class MqttConfiguration extends Object
Sets up Eclipse Paho for communicating with MQ-TT broker using configurations
  • Field Details

    • logger

      org.slf4j.Logger logger
    • hostURI

      @Value("${mqtt.connection.ServerURIs}") private String hostURI
    • basePublishTopic

      @Value("${mqtt.publish.base.topic:chenile}") String basePublishTopic
      This is the base publish topic that will be pre-pended to publish messages. This can contain specific expressions such as {tenantId} for example which will be substituted by the actual tenantId at the time of publishing a message. This value may not be the same as the base subscribe topic because publishing happens at runtime while subscription happens during startup. Hence, subscription can contain wild cards (such as +) whereas publishing may include expressions that will be substituted from the headers (such as tenant Id etc.) But if it is a constant expression they both can be the same. (default: chenile)
    • baseSubscribeTopic

      @Value("${mqtt.subscribe.base.topic:chenile}") private String baseSubscribeTopic
      This is the base topic name that will pre-pended for all subscriptions. It can contain wild cards such as + in accordance with the MQ-TT subscription rules . (default: chenile)
    • willPayload

      @Value("${mqtt.will.payload}") private String willPayload
    • willQos

      @Value("${mqtt.will.qos}") private int willQos
    • willRetained

      @Value("${mqtt.will.retained}") private boolean willRetained
    • willTopic

      @Value("${mqtt.will.topic}") private String willTopic
    • clientID

      @Value("${mqtt.clientID}") private String clientID
    • actionTimeout

      @Value("${mqtt.actionTimeout}") private int actionTimeout
    • mqttEnabled

      @Value("${mqtt.enabled:true}") private boolean mqttEnabled
    • sessionExpiry

      @Value("${mqtt.connection.session.expiry}") private Long sessionExpiry
  • Constructor Details

    • MqttConfiguration

      public MqttConfiguration()
  • Method Details

    • mqttConnectionDetails

      @Bean public Map<String,String> mqttConnectionDetails()
    • convertStringToBytes

      @Bean @ConfigurationPropertiesBinding Converter<String,byte[]> convertStringToBytes()
      This converts a string to a byte array. This is required to convert the password which is given in the properties file as a string to a byte array that can be set in conn opts
      Returns:
    • mqttConnectionOpts

      @Bean @ConfigurationProperties(prefix="mqtt.connection") org.eclipse.paho.mqttv5.client.MqttConnectionOptions mqttConnectionOpts()
    • willMessage

      @Bean org.eclipse.paho.mqttv5.common.MqttMessage willMessage(@Autowired org.eclipse.paho.mqttv5.client.MqttConnectionOptions options)
    • memoryPersistence

      @Bean org.eclipse.paho.mqttv5.client.persist.MemoryPersistence memoryPersistence()
    • disconnectedBufferOptions

      @Bean @ConfigurationProperties(prefix="mqtt.disconnected.buffer") org.eclipse.paho.mqttv5.client.DisconnectedBufferOptions disconnectedBufferOptions()
    • mqttV5Client

      @Bean org.eclipse.paho.mqttv5.client.MqttAsyncClient mqttV5Client(@Autowired @Qualifier("mqttConnectionDetails") Map<String,String> mqttConnectionDetails, @Autowired org.eclipse.paho.mqttv5.client.MqttConnectionOptions connOpts, @Autowired org.eclipse.paho.mqttv5.client.persist.MemoryPersistence persistence, @Autowired org.eclipse.paho.mqttv5.client.DisconnectedBufferOptions disconnectedBufferOptions) throws org.eclipse.paho.mqttv5.common.MqttException
      Throws:
      org.eclipse.paho.mqttv5.common.MqttException
    • mqttSubscriber

      @Bean MqttSubscriber mqttSubscriber(@Autowired org.eclipse.paho.mqttv5.client.MqttAsyncClient v5Client)
    • mqttPublisher

      @Bean @ConfigurationProperties(prefix="mqtt.publish") MqttPublisher mqttPublisher()
    • mqttEntryPoint

      @Bean MqttEntryPoint mqttEntryPoint()
    • mqttInitializer

      @Bean MqttInitializer mqttInitializer()
    • mqttConfig

      @Bean Map<String,String> mqttConfig()
      A topic to service map.
      This map is internally used to route a message that arrives at a topic to a service.
      This map is populated by the MqttInitializer during the initialization phase.
      It is used by the MqttEntryPoint during runtime to invoke the appropriate operation in a service
      Returns:
      a configuration that maps a route to a service.
    • mqttInfoProvider

      @Bean MqttInfoProvider mqttInfoProvider()